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 = 0xff;
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 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
60 char const * const legal_id_bytes =
61 "0123456789abcdef"
62 ;
63
64 // all the ASCII characters (bytes) which are legal in an ACE string
65 char const * const legal_ace_bytes =
66 // LDH characters
67 "abcdefghijklmnopqrstuvwxyz"
68 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
69 "0123456789"
70 "-"
71 // label separators
72 ".@"
73 ;
74
75 // all the ASCII characters (bytes) which can occur in cert names
76 char const * const legal_cert_name_bytes =
77 // LDH characters
78 "abcdefghijklmnopqrstuvwxyz"
79 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
80 "0123456789"
81 "-"
82 ;
83
84 // all the ASCII characters (bytes) which can occur in key names
85 char const * const legal_key_name_bytes =
86 // LDH characters
87 "abcdefghijklmnopqrstuvwxyz"
88 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
89 "0123456789"
90 "-"
91 // other non-shell, non-selector metacharacters allowed in (unquoted) local
92 // parts by RFC2821/RFC2822. The full list is !#$%&'*+-/=?^_`|{}~.
93 "+_."
94 // label and component separators
95 ".@"
96 ;
97
98 // all the ASCII characters (bytes) which are illegal in a (file|local)_path
99
100 char const illegal_path_bytes_arr[33] =
101 {
102 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
103 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
104 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
105 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
106 0x7f, 0x00
107 }
108 ;
109
110 char const * const illegal_path_bytes =
111 illegal_path_bytes_arr
112 ;
113
114 // how many revisions back to verify the sanity of revisions before allowing
115 // them into the database
116 int const verify_depth = 4;
117
118 // merkle tree / netcmd / netsync related stuff
119
120 size_t const merkle_fanout_bits = 4;
121
122 // all other merkle constants are derived
123 size_t const merkle_hash_length_in_bits = merkle_hash_length_in_bytes * 8;
124 size_t const merkle_num_tree_levels = merkle_hash_length_in_bits / merkle_fanout_bits;
125 size_t const merkle_num_slots = 1 << merkle_fanout_bits;
126 size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
127 size_t const merkle_bitmap_length_in_bytes = merkle_bitmap_length_in_bits / 8;
128
129 BOOST_STATIC_ASSERT(sizeof(char) == 1);
130 BOOST_STATIC_ASSERT(CHAR_BIT == 8);
131 BOOST_STATIC_ASSERT(merkle_num_tree_levels > 0);
132 BOOST_STATIC_ASSERT(merkle_num_tree_levels < 256);
133 BOOST_STATIC_ASSERT(merkle_fanout_bits > 0);
134 BOOST_STATIC_ASSERT(merkle_fanout_bits < 32);
135 BOOST_STATIC_ASSERT(merkle_hash_length_in_bits > 0);
136 BOOST_STATIC_ASSERT((merkle_hash_length_in_bits % merkle_fanout_bits) == 0);
137 BOOST_STATIC_ASSERT(merkle_bitmap_length_in_bits > 0);
138 BOOST_STATIC_ASSERT((merkle_bitmap_length_in_bits % 8) == 0);
139
140 u8 const netcmd_current_protocol_version = 5;
141
142 // allow payloads up to 256 megs (this sets the in-practice maximum size of
143 // a compressed file/manifest).
144 size_t const netcmd_minimum_bytes_to_bother_with_gzip = 0xfff;
145
146 size_t const netsync_session_key_length_in_bytes = 20; // 160 bits
147 size_t const netsync_hmac_value_length_in_bytes = 20; // 160 bits
148
149 std::string const & netsync_key_initializer = std::string(netsync_session_key_length_in_bytes, 0);
150
151}

Archive Download this file

Branches

Tags

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