forked from libbitcoin/libbitcoin-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.cpp
More file actions
102 lines (89 loc) · 2.98 KB
/
settings.cpp
File metadata and controls
102 lines (89 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bitcoin/node/settings.hpp>
#include <algorithm>
#include <filesystem>
#include <bitcoin/node/define.hpp>
using namespace bc::system;
using namespace bc::network;
namespace libbitcoin {
namespace node {
settings::settings() NOEXCEPT
: delay_inbound{ true },
headers_first{ true },
memory_priority{ true },
thread_priority{ true },
defer_validation{ false },
defer_confirmation{ false },
minimum_fee_rate{ 0.0 },
minimum_bump_rate{ 0.0 },
allowed_deviation{ 1.5 },
announcement_cache{ 42 },
allocation_multiple{ 20 },
////snapshot_bytes{ 200'000'000'000 },
////snapshot_valid{ 250'000 },
////snapshot_confirm{ 500'000 },
maximum_height{ 0 },
maximum_concurrency{ 50'000 },
sample_period_seconds{ 10 },
currency_window_minutes{ 60 },
threads{ 1 }
{
}
settings::settings(chain::selection) NOEXCEPT
: settings()
{
// TODO: testnet, etc. maximum_concurrency.
}
size_t settings::threads_() const NOEXCEPT
{
return std::max<size_t>(threads, one);
}
size_t settings::maximum_height_() const NOEXCEPT
{
return to_bool(maximum_height) ? maximum_height : max_size_t;
}
size_t settings::maximum_concurrency_() const NOEXCEPT
{
return to_bool(maximum_concurrency) ? maximum_concurrency : max_size_t;
}
network::steady_clock::duration settings::sample_period() const NOEXCEPT
{
return network::seconds(sample_period_seconds);
}
network::wall_clock::duration settings::currency_window() const NOEXCEPT
{
return network::minutes(currency_window_minutes);
}
network::processing_priority settings::thread_priority_() const NOEXCEPT
{
// medium is "normal" (os default), so true is a behavior change.
// highest is too much, as it makes the opreating system UI unresponsive.
return thread_priority ? network::processing_priority::high :
network::processing_priority::medium;
}
network::memory_priority settings::memory_priority_() const NOEXCEPT
{
// highest is "normal" (os default), so false is a behavior change.
// highest is the OS default, so far low does not have a noticeable effect.
return memory_priority ? network::memory_priority::highest :
network::memory_priority::low;
}
} // namespace node
} // namespace libbitcoin