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 characters in a SHA1 id
22 size_t const idlen = 40;
23
24 // number of characters in an epoch_data
25 size_t const epochlen = idlen;
26
27 // number of characters in an epoch_data
28 size_t const epochlen_bytes = epochlen / 2;
29
30 // number of seconds in window, in which to consider CVS commits equivalent
31 // if they have otherwise compatible contents (author, changelog)
32 size_t const cvs_window = 3600 * 3;
33
34 // number of bytes in a password buffer. further bytes will be dropped.
35 size_t const maxpasswd = 0xfff;
36
37 // number of bytes to use in buffers, for buffered i/o operations
38 size_t const bufsz = 0xfff;
39
40 // size of a line of database traffic logging, beyond which lines will be
41 // truncated.
42 size_t const db_log_line_sz = 70;
43
44 // size in bytes of the database xdelta version reconstruction cache
45 size_t const db_version_cache_sz = 1 << 20;
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 cert names
83 char const * const legal_cert_name_bytes =
84 // LDH characters
85 "abcdefghijklmnopqrstuvwxyz"
86 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
87 "0123456789"
88 "-"
89 ;
90
91 // all the ASCII characters (bytes) which can occur in key names
92 char const * const legal_key_name_bytes =
93 // LDH characters
94 "abcdefghijklmnopqrstuvwxyz"
95 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
96 "0123456789"
97 "-"
98 // label and component separators
99 ".@"
100 ;
101
102 // all the ASCII characters (bytes) which are illegal in a (file|local)_path
103
104 char const illegal_path_bytes_arr[33] =
105 {
106 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
107 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
108 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
109 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
110 0x7f, 0x00
111 }
112 ;
113
114 char const * const illegal_path_bytes =
115 illegal_path_bytes_arr
116 ;
117
118 // how many revisions back to verify the sanity of revisions before allowing
119 // them into the database
120 int const verify_depth = 4;
121
122 // merkle tree / netcmd / netsync related stuff
123
124 size_t const merkle_hash_length_in_bytes = 20;
125 size_t const merkle_fanout_bits = 4;
126
127 // all other merkle constants are derived
128 size_t const merkle_hash_length_in_bits = merkle_hash_length_in_bytes * 8;
129 size_t const merkle_num_tree_levels = merkle_hash_length_in_bits / merkle_fanout_bits;
130 size_t const merkle_num_slots = 1 << merkle_fanout_bits;
131 size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
132 size_t const merkle_bitmap_length_in_bytes = merkle_bitmap_length_in_bits / 8;
133
134 BOOST_STATIC_ASSERT(sizeof(char) == 1);
135 BOOST_STATIC_ASSERT(CHAR_BIT == 8);
136 BOOST_STATIC_ASSERT(merkle_num_tree_levels > 0);
137 BOOST_STATIC_ASSERT(merkle_num_tree_levels < 256);
138 BOOST_STATIC_ASSERT(merkle_fanout_bits > 0);
139 BOOST_STATIC_ASSERT(merkle_fanout_bits < 32);
140 BOOST_STATIC_ASSERT(merkle_hash_length_in_bits > 0);
141 BOOST_STATIC_ASSERT((merkle_hash_length_in_bits % merkle_fanout_bits) == 0);
142 BOOST_STATIC_ASSERT(merkle_bitmap_length_in_bits > 0);
143 BOOST_STATIC_ASSERT((merkle_bitmap_length_in_bits % 8) == 0);
144
145 u8 const netcmd_current_protocol_version = 4;
146 size_t const netcmd_minsz = (1 // version
147 + 1 // cmd code
148 + 1 // smallest uleb possible
149 + 4); // adler32
150
151 // allow payloads up to 256 megs (this sets the in-practice maximum size of
152 // a compressed file/manifest).
153 size_t const netcmd_payload_limit = 2 << 27;
154 size_t const netcmd_maxsz = netcmd_minsz + netcmd_payload_limit;
155 size_t const netcmd_minimum_bytes_to_bother_with_gzip = 0xfff;
156
157 size_t const netsync_default_port = 5253;
158 size_t const netsync_connection_limit = 1024;
159 size_t const netsync_timeout_seconds = 21600; // 6 hours
160
161}

Archive Download this file

Branches

Tags

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