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 // block size in bytes for "automate stdio" output
24 size_t const automate_stdio_size = 1024;
25
26 // number of bits in an RSA key we use
27 size_t const keylen = 1024;
28
29 // number of seconds in window, in which to consider CVS commits equivalent
30 // if they have otherwise compatible contents (author, changelog)
31 time_t const cvs_window = 60 * 5;
32
33 // size of a line of database traffic logging, beyond which lines will be
34 // truncated.
35 size_t const db_log_line_sz = 70;
36
37 size_t const default_terminal_width = 72;
38
39 // size in bytes of the database xdelta version reconstruction cache.
40 // the value of 7 MB was determined as the optimal point after timing
41 // various values with a pull of the monotone repository - it could
42 // be tweaked further.
43 size_t db_version_cache_sz = 7 * (1 << 20);
44
45 size_t const db_roster_cache_sz = 7;
46
47 // Want to keep this larger than database.hh:checkpoint_batch_bytes
48 unsigned long const db_max_pending_writes_bytes = 16 * 1024 * 1024;
49
50 // size of a line of text in the log buffer, beyond which log lines will be
51 // truncated.
52 size_t const log_line_sz = 0x300;
53
54 // all the ASCII characters (bytes) which are legal in a packet.
55 char const * const legal_packet_bytes =
56 // LDH characters
57 "abcdefghijklmnopqrstuvwxyz"
58 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
59 "0123456789"
60 "-"
61 // extra base64 codes
62 "+/="
63 // separators
64 ".@[]"
65 // whitespace
66 " \r\n\t"
67 ;
68
69 string const regex_legal_packet_bytes("([a-zA-Z0-9+/=[:space:]]+)");
70
71 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
72 char const * const legal_id_bytes =
73 "0123456789abcdef"
74 ;
75
76 string const regex_legal_id_bytes("([[:xdigit:]]{40})");
77
78 // all the ASCII characters (bytes) which are legal in an ACE string
79 char const * const legal_ace_bytes =
80 // LDH characters
81 "abcdefghijklmnopqrstuvwxyz"
82 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
83 "0123456789"
84 "-"
85 // label separators
86 ".@"
87 ;
88
89 // all the ASCII characters (bytes) which can occur in cert names
90 char const * const legal_cert_name_bytes =
91 // LDH characters
92 "abcdefghijklmnopqrstuvwxyz"
93 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
94 "0123456789"
95 "-"
96 ;
97
98 string const regex_legal_cert_name_bytes("([-a-zA-Z0-9]+)");
99
100 // all the ASCII characters (bytes) which can occur in key names
101 char const * const legal_key_name_bytes =
102 // LDH characters
103 "abcdefghijklmnopqrstuvwxyz"
104 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
105 "0123456789"
106 "-"
107 // other non-shell, non-selector metacharacters allowed in (unquoted) local
108 // parts by RFC2821/RFC2822. The full list is !#$%&'*+-/=?^_`|{}~.
109 "+_."
110 // label and component separators
111 ".@"
112 ;
113
114 string const regex_legal_key_name_bytes("([-a-zA-Z0-9\\.@\\+_]+)");
115
116 // merkle tree / netcmd / netsync related stuff
117
118 size_t const merkle_fanout_bits = 4;
119
120 // all other merkle constants are derived
121 size_t const merkle_hash_length_in_bits = merkle_hash_length_in_bytes * 8;
122 size_t const merkle_num_tree_levels = merkle_hash_length_in_bits / merkle_fanout_bits;
123 size_t const merkle_num_slots = 1 << merkle_fanout_bits;
124 size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
125 size_t const merkle_bitmap_length_in_bytes = merkle_bitmap_length_in_bits / 8;
126
127 BOOST_STATIC_ASSERT(sizeof(char) == 1);
128 BOOST_STATIC_ASSERT(CHAR_BIT == 8);
129 BOOST_STATIC_ASSERT(merkle_num_tree_levels > 0);
130 BOOST_STATIC_ASSERT(merkle_num_tree_levels < 256);
131 BOOST_STATIC_ASSERT(merkle_fanout_bits > 0);
132 BOOST_STATIC_ASSERT(merkle_fanout_bits < 32);
133 BOOST_STATIC_ASSERT(merkle_hash_length_in_bits > 0);
134 BOOST_STATIC_ASSERT((merkle_hash_length_in_bits % merkle_fanout_bits) == 0);
135 BOOST_STATIC_ASSERT(merkle_bitmap_length_in_bits > 0);
136 BOOST_STATIC_ASSERT((merkle_bitmap_length_in_bits % 8) == 0);
137
138 u8 const netcmd_current_protocol_version = 6;
139
140 size_t const netcmd_minimum_bytes_to_bother_with_gzip = 0xfff;
141
142 size_t const netsync_session_key_length_in_bytes = 20; // 160 bits
143 size_t const netsync_hmac_value_length_in_bytes = 20; // 160 bits
144
145 string const & netsync_key_initializer = string(netsync_session_key_length_in_bytes, 0);
146
147 // attributes
148 string const encoding_attribute("mtn:encoding");
149 string const manual_merge_attribute("mtn:manual_merge");
150 string const binary_encoding("binary");
151 string const default_encoding("default");
152}
153
154// Local Variables:
155// mode: C++
156// fill-column: 76
157// c-file-style: "gnu"
158// indent-tabs-mode: nil
159// End:
160// 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