forked from libbitcoin/libbitcoin-node
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchaser.cpp
More file actions
206 lines (166 loc) · 4.47 KB
/
Copy pathchaser.cpp
File metadata and controls
206 lines (166 loc) · 4.47 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**
* Copyright (c) 2011-2026 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/chasers/chaser.hpp>
#include <mutex>
#include <bitcoin/node/configuration.hpp>
#include <bitcoin/node/define.hpp>
#include <bitcoin/node/full_node.hpp>
namespace libbitcoin {
namespace node {
using namespace network;
using namespace system::chain;
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
chaser::chaser(full_node& node) NOEXCEPT
: node_(node),
strand_(node.service().get_executor()),
top_checkpoint_height_(node.system_settings().top_checkpoint().height()),
reporter(node.log)
{
}
// Methods.
// ----------------------------------------------------------------------------
void chaser::stopping(const code&) NOEXCEPT
{
}
void chaser::stop() NOEXCEPT
{
}
bool chaser::closed() const NOEXCEPT
{
return node_.closed();
}
bool chaser::suspended() const NOEXCEPT
{
return node_.suspended();
}
code chaser::fault(const code& ec) NOEXCEPT
{
node_.fault(ec);
return ec;
}
void chaser::resume() NOEXCEPT
{
node_.resume();
}
code chaser::prune(const store::event_handler& handler) NOEXCEPT
{
return node_.prune(handler);
}
code chaser::snapshot(const store::event_handler& handler) NOEXCEPT
{
return node_.snapshot(handler);
}
code chaser::reload(const store::event_handler& handler) NOEXCEPT
{
return node_.reload(handler);
}
// Events.
// ----------------------------------------------------------------------------
object_key chaser::subscribe_chase(event_notifier&& handler) NOEXCEPT
{
return node_.subscribe_chase(std::move(handler));
}
void chaser::notify(const code& ec, chase event_,
event_value value) const NOEXCEPT
{
node_.notify(ec, event_, value);
}
void chaser::notify_one(object_key key, const code& ec, chase event_,
event_value value) const NOEXCEPT
{
node_.notify_one(key, ec, event_, value);
}
// Strand.
// ----------------------------------------------------------------------------
asio::strand& chaser::strand() NOEXCEPT
{
return strand_;
}
bool chaser::stranded() const NOEXCEPT
{
return strand_.running_in_this_thread();
}
// Properties.
// ----------------------------------------------------------------------------
query& chaser::archive() const NOEXCEPT
{
return node_.archive();
}
const node::configuration& chaser::node_config() const NOEXCEPT
{
return node_.node_config();
}
const system::settings& chaser::system_settings() const NOEXCEPT
{
return node_.system_settings();
}
const database::settings& chaser::database_settings() const NOEXCEPT
{
return node_.database_settings();
}
const network::settings& chaser::network_settings() const NOEXCEPT
{
return node_.network_settings();
}
const node::settings& chaser::node_settings() const NOEXCEPT
{
return node_.node_settings();
}
bool chaser::is_current(bool confirmed) const NOEXCEPT
{
return node_.is_current(confirmed);
}
bool chaser::is_current(uint32_t timestamp) const NOEXCEPT
{
return node_.is_current(timestamp);
}
// get_timestamp error results in false (ok).
bool chaser::is_current(const database::header_link& link) const NOEXCEPT
{
return node_.is_current(link);
}
bool chaser::is_recent() const NOEXCEPT
{
return node_.is_recent();
}
bool chaser::is_under_checkpoint(size_t height) const NOEXCEPT
{
return height <= checkpoint();
}
size_t chaser::checkpoint() const NOEXCEPT
{
return top_checkpoint_height_;
}
// Position.
// ----------------------------------------------------------------------------
size_t chaser::position() const NOEXCEPT
{
// Called from start.
////BC_ASSERT(stranded());
return position_;
}
void chaser::set_position(size_t height) NOEXCEPT
{
// Called from start.
////BC_ASSERT(stranded());
position_ = height;
}
BC_POP_WARNING()
} // namespace node
} // namespace libbitcoin