monotone

monotone Mtn Source Tree

Root/constants.cc

1// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10// this file contains magic constants which you could, in theory, tweak.
11// probably best not to tweak them though.
12
13#include "constants.hh"
14#include "numeric_vocab.hh"
15
16#include <boost/static_assert.hpp>
17
18using std::string;
19
20namespace constants
21{
22
23 // number of bits in an RSA key we use
24 size_t const keylen = 1024;
25
26 // number of seconds in window, in which to consider CVS commits equivalent
27 // if they have otherwise compatible contents (author, changelog)
28 time_t const cvs_window = 60 * 5;
29
30 // size of a line of database traffic logging, beyond which lines will be
31 // truncated.
32 size_t const db_log_line_sz = 70;
33
34 size_t const default_terminal_width = 72;
35
36 // size in bytes of the database xdelta version reconstruction cache.
37 // the value of 7 MB was determined as the optimal point after timing
38 // various values with a pull of the monotone repository - it could
39 // be tweaked further.
40 size_t const db_version_cache_sz = 7 * (1 << 20);
41
42 // the value of 7 MB was determined by blindly copying the line above and
43 // not doing any testing at all - it could be tweaked further.
44 size_t const db_roster_cache_sz = 7 * (1 << 20);
45
46 // this value is very much an estimate. the calculation is:
47 // -- 40 bytes content hash
48 // -- a path component, maybe 10 or 15 bytes
49 // -- 40 bytes birth revision
50 // -- 40 bytes name marking hash
51 // -- 40 bytes content marking hash
52 // -- plus internal pointers, etc., for strings, sets, shared_ptrs, heap
53 // overhead, ...
54 // -- plus any space taken for attrs
55 // so ~175 bytes for a file node, plus internal slop, plus attrs (another
56 // 60 bytes per attr, or so), minus 80 bytes for dir nodes. So this just
57 // picks a number that seems a reasonable amount over 175.
58 size_t const db_estimated_roster_node_sz = 210;
59
60 unsigned long const db_max_delayed_file_bytes = 16 * 1024 * 1024;
61
62 // size of a line of text in the log buffer, beyond which log lines will be
63 // truncated.
64 size_t const log_line_sz = 0x300;
65
66 // all the ASCII characters (bytes) which are legal in a packet.
67 char const * const legal_packet_bytes =
68 // LDH characters
69 "abcdefghijklmnopqrstuvwxyz"
70 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
71 "0123456789"
72 "-"
73 // extra base64 codes
74 "+/="
75 // separators
76 ".@[]"
77 // whitespace
78 " \r\n\t"
79 ;
80
81 string const regex_legal_packet_bytes("([a-zA-Z0-9+/=[:space:]]+)");
82
83 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
84 char const * const legal_id_bytes =
85 "0123456789abcdef"
86 ;
87
88 string const regex_legal_id_bytes("([0-9a-f]{40})");
89
90 // all the ASCII characters (bytes) which are legal in an ACE string
91 char const * const legal_ace_bytes =
92 // LDH characters
93 "abcdefghijklmnopqrstuvwxyz"
94 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
95 "0123456789"
96 "-"
97 // label separators
98 ".@"
99 ;
100
101 // all the ASCII characters (bytes) which can occur in cert names
102 char const * const legal_cert_name_bytes =
103 // LDH characters
104 "abcdefghijklmnopqrstuvwxyz"
105 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
106 "0123456789"
107 "-"
108 ;
109
110 string const regex_legal_cert_name_bytes("([-a-zA-Z0-9]+)");
111
112 // all the ASCII characters (bytes) which can occur in key names
113 char const * const legal_key_name_bytes =
114 // LDH characters
115 "abcdefghijklmnopqrstuvwxyz"
116 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
117 "0123456789"
118 "-"
119 // other non-shell, non-selector metacharacters allowed in (unquoted) local
120 // parts by RFC2821/RFC2822. The full list is !#$%&'*+-/=?^_`|{}~.
121 "+_."
122 // label and component separators
123 ".@"
124 ;
125
126 string const regex_legal_key_name_bytes("([-a-zA-Z0-9\\.@\\+_]+)");
127
128 // merkle tree / netcmd / netsync related stuff
129
130 size_t const merkle_fanout_bits = 4;
131
132 // all other merkle constants are derived
133 size_t const merkle_hash_length_in_bits = merkle_hash_length_in_bytes * 8;
134 size_t const merkle_num_tree_levels = merkle_hash_length_in_bits / merkle_fanout_bits;
135 size_t const merkle_num_slots = 1 << merkle_fanout_bits;
136 size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
137 size_t const merkle_bitmap_length_in_bytes = merkle_bitmap_length_in_bits / 8;
138
139 BOOST_STATIC_ASSERT(sizeof(char) == 1);
140 BOOST_STATIC_ASSERT(CHAR_BIT == 8);
141 BOOST_STATIC_ASSERT(merkle_num_tree_levels > 0);
142 BOOST_STATIC_ASSERT(merkle_num_tree_levels < 256);
143 BOOST_STATIC_ASSERT(merkle_fanout_bits > 0);
144 BOOST_STATIC_ASSERT(merkle_fanout_bits < 32);
145 BOOST_STATIC_ASSERT(merkle_hash_length_in_bits > 0);
146 BOOST_STATIC_ASSERT((merkle_hash_length_in_bits % merkle_fanout_bits) == 0);
147 BOOST_STATIC_ASSERT(merkle_bitmap_length_in_bits > 0);
148 BOOST_STATIC_ASSERT((merkle_bitmap_length_in_bits % 8) == 0);
149
150 u8 const netcmd_current_protocol_version = 6;
151
152 size_t const netcmd_minimum_bytes_to_bother_with_gzip = 0xfff;
153
154 size_t const netsync_session_key_length_in_bytes = 20; // 160 bits
155 size_t const netsync_hmac_value_length_in_bytes = 20; // 160 bits
156
157 netsync_session_key const netsync_key_initializer(string(netsync_session_key_length_in_bytes, 0));
158
159 // attributes
160 string const encoding_attribute("mtn:encoding");
161 string const manual_merge_attribute("mtn:manual_merge");
162 string const binary_encoding("binary");
163 string const default_encoding("default");
164}
165
166// Local Variables:
167// mode: C++
168// fill-column: 76
169// c-file-style: "gnu"
170// indent-tabs-mode: nil
171// End:
172// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status