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 // number of bits in an RSA key we use
19 size_t const keylen = 1024;
20
21 // number of bytes of random noise we seed vcheck packets with
22 size_t const vchecklen = 32;
23
24 // number of characters in a SHA1 id
25 size_t const idlen = 40;
26
27 // number of seconds in window, in which to consider CVS commits equivalent
28 // if they have otherwise compatible contents (author, changelog)
29 size_t const cvs_window = 3600 * 3;
30
31 // number of bytes accepted in a database row (also used as a file upload
32 // limit in the depot code).
33 size_t const maxbytes = 0xffffff;
34
35 // advisory number of bytes sent in a single network transmission; not a
36 // strict limit (single packets beyond this size will post as a unit) but a
37 // "suggested maximum size" for each posting.
38 size_t const postsz = 0xffff;
39
40 // number of bytes to use in buffers, for buffered i/o operations
41 size_t const bufsz = 0xfff;
42
43 // size of a line of database traffic logging, beyond which lines will be
44 // truncated.
45 size_t const db_log_line_sz = 70;
46
47 // size of a line of text in the log buffer, beyond which log lines will be
48 // truncated.
49 size_t const log_line_sz = 0xff;
50
51 // all the ASCII characters (bytes) which are legal in a packet.
52 char const * const legal_packet_bytes =
53 // LDH characters
54 "abcdefghijklmnopqrstuvwxyz"
55 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
56 "0123456789"
57 "-"
58 // extra base64 codes
59 "+/="
60 // separators
61 ".@[]"
62 // whitespace
63 " \r\n\t"
64 ;
65
66 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
67 char const * const legal_id_bytes =
68 "0123456789abcdef"
69 ;
70
71 // all the ASCII characters (bytes) which are legal in an ACE string
72 char const * const legal_ace_bytes =
73 // LDH characters
74 "abcdefghijklmnopqrstuvwxyz"
75 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
76 "0123456789"
77 "-"
78 // label separators
79 ".@"
80 ;
81
82 // all the ASCII characters (bytes) which can occur in URLs
83 char const * const legal_url_bytes =
84 // alphanumerics
85 "abcdefghijklmnopqrstuvwxyz"
86 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
87 "0123456789"
88 // mark chars
89 "-_.!~*'()"
90 // extra path chars
91 ":@&=+$,"
92 // path separator
93 "/"
94 // escape char
95 "%"
96 ;
97
98 // all the ASCII characters (bytes) which can occur in cert names
99 char const * const legal_cert_name_bytes =
100 // LDH characters
101 "abcdefghijklmnopqrstuvwxyz"
102 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
103 "0123456789"
104 "-"
105 ;
106
107 // all the ASCII characters (bytes) which can occur in key names
108 char const * const legal_key_name_bytes =
109 // LDH characters
110 "abcdefghijklmnopqrstuvwxyz"
111 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
112 "0123456789"
113 "-"
114 // label and component separators
115 ".@"
116 ;
117
118 // all the ASCII characters (bytes) which are illegal in a (file|local)_path
119
120 char const illegal_path_bytes_arr[33] =
121 {
122 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
123 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
124 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
125 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
126 0x7f, 0x00
127 }
128 ;
129
130 char const * const illegal_path_bytes =
131 illegal_path_bytes_arr
132 ;
133
134 // merkle tree / netcmd / netsync related stuff
135
136 size_t const merkle_hash_length_in_bytes = 20;
137 size_t const merkle_fanout_bits = 4;
138
139 // all other merkle constants are derived
140 size_t const merkle_hash_length_in_bits = merkle_hash_length_in_bytes * 8;
141 size_t const merkle_num_tree_levels = merkle_hash_length_in_bits / merkle_fanout_bits;
142 size_t const merkle_num_slots = 1 << merkle_fanout_bits;
143 size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
144 size_t const merkle_bitmap_length_in_bytes = merkle_bitmap_length_in_bits / 8;
145
146 BOOST_STATIC_ASSERT(sizeof(char) == 1);
147 BOOST_STATIC_ASSERT(CHAR_BIT == 8);
148 BOOST_STATIC_ASSERT(merkle_num_tree_levels > 0);
149 BOOST_STATIC_ASSERT(merkle_num_tree_levels < 256);
150 BOOST_STATIC_ASSERT(merkle_fanout_bits > 0);
151 BOOST_STATIC_ASSERT(merkle_fanout_bits < 32);
152 BOOST_STATIC_ASSERT(merkle_hash_length_in_bits > 0);
153 BOOST_STATIC_ASSERT((merkle_hash_length_in_bits % merkle_fanout_bits) == 0);
154 BOOST_STATIC_ASSERT(merkle_bitmap_length_in_bits > 0);
155 BOOST_STATIC_ASSERT((merkle_bitmap_length_in_bits % 8) == 0);
156
157 u8 const netcmd_current_protocol_version = 1;
158 size_t const netcmd_minsz = (1 // version
159 + 1 // cmd code
160 + 1 // smallest uleb possible
161 + 4); // adler32
162
163 size_t const netcmd_payload_limit = 0xffffff;
164 size_t const netcmd_maxsz = netcmd_minsz + netcmd_payload_limit;
165 size_t const netcmd_minimum_bytes_to_bother_with_gzip = 64;
166
167 size_t const netsync_default_port = 5253;
168 size_t const netsync_connection_limit = 100;
169 size_t const netsync_timeout_seconds = 120;
170
171}

Archive Download this file

Branches

Tags

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