monotone

monotone Mtn Source Tree

Root/constants.hh

1#ifndef __CONSTANTS_HH__
2#define __CONSTANTS_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include <cstddef>
14#include <ctime>
15#include "numeric_vocab.hh"
16
17namespace constants
18{
19 // this file contains magic constants which you could, in theory, tweak.
20 // probably best not to tweak them though.
21 // all scalar constants are defined in this file so their values are
22 // visible to the compiler; aggregate constants are defined in
23 // constants.cc, which also has some static assertions to make sure
24 // everything is consistent.
25
26 // number of bits in an RSA key we use
27 std::size_t const keylen = 1024;
28
29 // number of characters in a SHA1 id
30 std::size_t const idlen = 40;
31
32 // number of binary bytes, ditto
33 std::size_t const idlen_bytes = idlen / 2;
34
35 // number of characters in an encoded epoch
36 std::size_t const epochlen = idlen;
37
38 // number of characters in a raw epoch
39 std::size_t const epochlen_bytes = idlen_bytes;
40
41 // number of seconds in window, in which to consider CVS commits equivalent
42 // if they have otherwise compatible contents (author, changelog)
43 std::time_t const cvs_window = 60 * 5;
44
45 // number of bytes in a password buffer. further bytes will be dropped.
46 std::size_t const maxpasswd = 0xfff;
47
48 // number of bytes to use in buffers, for buffered i/o operations
49 std::size_t const bufsz = 0x3ffff;
50
51 // size of a line of database traffic logging, beyond which lines will be
52 // truncated.
53 std::size_t const db_log_line_sz = 50;
54
55 // maximum size in bytes of the database xdelta version reconstruction
56 // cache. the value of 7 MB was determined as the optimal point after
57 // timing various values with a pull of the monotone repository - it could
58 // be tweaked further.
59 std::size_t const db_version_cache_sz = 7 * (1 << 20);
60
61 // maximum size in bytes of the write-back roster cache
62 // the value of 7 MB was determined by blindly copying the line above and
63 // not doing any testing at all - it could be tweaked further.
64 std::size_t const db_roster_cache_sz = 7 * (1 << 20);
65
66 // estimated number of bytes taken for a node_t and its corresponding
67 // marking_t. used to estimate the current size of the write-back roster
68 // cache. the calculation is:
69 // -- 40 bytes content hash
70 // -- a path component, maybe 10 or 15 bytes
71 // -- 40 bytes birth revision
72 // -- 40 bytes name marking hash
73 // -- 40 bytes content marking hash
74 // -- plus internal pointers, etc., for strings, sets, shared_ptrs, heap
75 // overhead, ...
76 // -- plus any space taken for attrs
77 // so ~175 bytes for a file node, plus internal slop, plus attrs (another
78 // 60 bytes per attr, or so), minus 80 bytes for dir nodes. So this just
79 // picks a number that seems a reasonable amount over 175.
80 std::size_t const db_estimated_roster_node_sz = 210;
81
82 // maximum number of bytes to be consumed with the delayed write cache
83 unsigned long const db_max_delayed_file_bytes = 16 * (1 << 20);
84
85 // size of a line of text in the log buffer, beyond which log lines will be
86 // truncated.
87 std::size_t const log_line_sz = 0x300;
88
89 // assumed width of the terminal, when we can't query for it directly
90 std::size_t const default_terminal_width = 72;
91
92 // all the ASCII characters (bytes) which are legal in a base64 blob
93 extern char const legal_base64_bytes[];
94
95 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
96 extern char const legal_id_bytes[];
97
98 // all the ASCII characters (bytes) which can occur in cert names
99 extern char const legal_cert_name_bytes[];
100
101 // all the ASCII characters (bytes) which can occur in key names
102 extern char const legal_key_name_bytes[];
103
104 // remaining constants are related to netsync protocol
105
106 // number of bytes in the hash used in netsync
107 std::size_t const merkle_hash_length_in_bytes = 20;
108
109 // number of bits of merkle prefix consumed by each level of tree
110 std::size_t const merkle_fanout_bits = 4;
111
112 // derived from hash_length_in_bytes
113 std::size_t const merkle_hash_length_in_bits
114 = merkle_hash_length_in_bytes * 8;
115
116 // derived from fanout_bits
117 std::size_t const merkle_num_tree_levels
118 = merkle_hash_length_in_bits / merkle_fanout_bits;
119
120 // derived from fanout_bits
121 std::size_t const merkle_num_slots = 1 << merkle_fanout_bits;
122
123 // derived from fanout_bits
124 std::size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
125
126 // derived from fanout_bits
127 std::size_t const merkle_bitmap_length_in_bytes
128 = merkle_bitmap_length_in_bits / 8;
129
130 // the current netcmd/netsync protocol version
131 u8 const netcmd_current_protocol_version = 6;
132
133 // minimum size of any netcmd on the wire
134 std::size_t const netcmd_minsz = (1 // version
135 + 1 // cmd code
136 + 1); // smallest uleb possible
137
138
139 // largest command *payload* allowed in a netcmd
140 // in practice, this sets the size of the largest compressed file
141 std::size_t const netcmd_payload_limit = 2 << 27;
142
143 // maximum size of any netcmd on the wire, including payload
144 std::size_t const netcmd_maxsz = netcmd_minsz + netcmd_payload_limit;
145
146 // netsync fragments larger than this are gzipped
147 std::size_t const netcmd_minimum_bytes_to_bother_with_gzip = 0xfff;
148
149 // TCP port to listen on / connect to when doing netsync
150 std::size_t const netsync_default_port = 4691;
151
152 // maximum number of simultaneous clients on a server
153 std::size_t const netsync_connection_limit = 1024;
154
155 // number of seconds a connection can be idle before it's dropped
156 std::size_t const netsync_timeout_seconds = 21600; // 6 hours
157
158 // netsync HMAC key length
159 std::size_t const netsync_session_key_length_in_bytes = 20;
160
161 // netsync HMAC value length
162 std::size_t const netsync_hmac_value_length_in_bytes = 20;
163
164 // how long a sha1 digest should be
165 std::size_t const sha1_digest_length = 20; // 160 bits
166
167 // netsync session key default initializer
168 extern char const netsync_key_initializer[];
169
170 // attributes
171 extern char const encoding_attribute[];
172 extern char const binary_encoding[];
173 extern char const default_encoding[];
174 extern char const manual_merge_attribute[];
175}
176
177// Local Variables:
178// mode: C++
179// fill-column: 76
180// c-file-style: "gnu"
181// indent-tabs-mode: nil
182// End:
183// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
184
185#endif // __CONSTANTS_HH__

Archive Download this file

Branches

Tags

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