monotone

monotone Mtn Source Tree

Root/constants.cc

1
2// copyright (C) 2002, 2003 graydon hoare <graydon@pobox.com>
3// all rights reserved.
4// licensed to the public under the terms of the GNU GPL (>= 2)
5// see the file COPYING for details
6
7// this file contains magic constants which you could, in theory, tweak.
8// probably best not to tweak them though.
9
10#include "constants.hh"
11#include "numeric_vocab.hh"
12
13#include <boost/static_assert.hpp>
14
15namespace constants
16{
17
18 // block size in bytes for "automate stdio" output
19 size_t const automate_stdio_size = 1024;
20
21 // number of bits in an RSA key we use
22 size_t const keylen = 1024;
23
24 // number of seconds in window, in which to consider CVS commits equivalent
25 // if they have otherwise compatible contents (author, changelog)
26 time_t const cvs_window = 60 * 5;
27
28 // size of a line of database traffic logging, beyond which lines will be
29 // truncated.
30 size_t const db_log_line_sz = 70;
31
32 size_t const default_terminal_width = 72;
33
34 // size in bytes of the database xdelta version reconstruction cache.
35 // the value of 7 MB was determined as the optimal point after timing
36 // various values with a pull of the monotone repository - it could
37 // be tweaked further.
38 size_t const db_version_cache_sz = 7 * (1 << 20);
39
40 // size of a line of text in the log buffer, beyond which log lines will be
41 // truncated.
42 size_t const log_line_sz = 0x300;
43
44 // all the ASCII characters (bytes) which are legal in a packet.
45 char const * const legal_packet_bytes =
46 // LDH characters
47 "abcdefghijklmnopqrstuvwxyz"
48 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
49 "0123456789"
50 "-"
51 // extra base64 codes
52 "+/="
53 // separators
54 ".@[]"
55 // whitespace
56 " \r\n\t"
57 ;
58
59 std::string const regex_legal_packet_bytes("([a-zA-Z0-9+/=[:space:]]+)");
60
61 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
62 char const * const legal_id_bytes =
63 "0123456789abcdef"
64 ;
65
66 std::string const regex_legal_id_bytes("([[:xdigit:]]{40})");
67
68 // all the ASCII characters (bytes) which are legal in an ACE string
69 char const * const legal_ace_bytes =
70 // LDH characters
71 "abcdefghijklmnopqrstuvwxyz"
72 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
73 "0123456789"
74 "-"
75 // label separators
76 ".@"
77 ;
78
79 // all the ASCII characters (bytes) which can occur in cert names
80 char const * const legal_cert_name_bytes =
81 // LDH characters
82 "abcdefghijklmnopqrstuvwxyz"
83 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
84 "0123456789"
85 "-"
86 ;
87
88 std::string const regex_legal_cert_name_bytes("([-a-zA-Z0-9]+)");
89
90 // all the ASCII characters (bytes) which can occur in key names
91 char const * const legal_key_name_bytes =
92 // LDH characters
93 "abcdefghijklmnopqrstuvwxyz"
94 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
95 "0123456789"
96 "-"
97 // other non-shell, non-selector metacharacters allowed in (unquoted) local
98 // parts by RFC2821/RFC2822. The full list is !#$%&'*+-/=?^_`|{}~.
99 "+_."
100 // label and component separators
101 ".@"
102 ;
103
104 std::string const regex_legal_key_name_bytes("([-a-zA-Z0-9\\.@\\+_]+)");
105
106 // all the ASCII characters (bytes) which are illegal in a (file|local)_path
107
108 char const illegal_path_bytes_arr[33] =
109 {
110 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
111 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
112 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
113 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
114 0x7f, 0x00
115 }
116 ;
117
118 char const * const illegal_path_bytes =
119 illegal_path_bytes_arr
120 ;
121
122 // how many revisions back to verify the sanity of revisions before allowing
123 // them into the database
124 int const verify_depth = 4;
125
126 // merkle tree / netcmd / netsync related stuff
127
128 size_t const merkle_fanout_bits = 4;
129
130 // all other merkle constants are derived
131 size_t const merkle_hash_length_in_bits = merkle_hash_length_in_bytes * 8;
132 size_t const merkle_num_tree_levels = merkle_hash_length_in_bits / merkle_fanout_bits;
133 size_t const merkle_num_slots = 1 << merkle_fanout_bits;
134 size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
135 size_t const merkle_bitmap_length_in_bytes = merkle_bitmap_length_in_bits / 8;
136
137 BOOST_STATIC_ASSERT(sizeof(char) == 1);
138 BOOST_STATIC_ASSERT(CHAR_BIT == 8);
139 BOOST_STATIC_ASSERT(merkle_num_tree_levels > 0);
140 BOOST_STATIC_ASSERT(merkle_num_tree_levels < 256);
141 BOOST_STATIC_ASSERT(merkle_fanout_bits > 0);
142 BOOST_STATIC_ASSERT(merkle_fanout_bits < 32);
143 BOOST_STATIC_ASSERT(merkle_hash_length_in_bits > 0);
144 BOOST_STATIC_ASSERT((merkle_hash_length_in_bits % merkle_fanout_bits) == 0);
145 BOOST_STATIC_ASSERT(merkle_bitmap_length_in_bits > 0);
146 BOOST_STATIC_ASSERT((merkle_bitmap_length_in_bits % 8) == 0);
147
148 u8 const netcmd_current_protocol_version = 5;
149
150 // allow payloads up to 256 megs (this sets the in-practice maximum size of
151 // a compressed file/manifest).
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 std::string const & netsync_key_initializer = std::string(netsync_session_key_length_in_bytes, 0);
158
159}

Archive Download this file

Branches

Tags

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