• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

libbitcoin / libbitcoin-node / 44232501441

18 Nov 2026 03:44AM UTC coverage: 90.915% (-0.2%) from 91.149%
44232501441

push

github

web-flow
Merge pull request #1269 from evoskuil/master

Add tidal pool.

399 of 442 new or added lines in 14 files covered. (90.27%)

9 existing lines in 5 files now uncovered.

4403 of 4843 relevant lines covered (90.91%)

4933.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.35
/src/protocols/protocol.cpp
1
/**
2
 * Copyright (c) 2011-2026 libbitcoin developers
3
 *
4
 * This file is part of libbitcoin.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
#include <bitcoin/node/protocols/protocol.hpp>
20

21
#include <bitcoin/node/configuration.hpp>
22
#include <bitcoin/node/define.hpp>
23

24
namespace libbitcoin {
25
namespace node {
26

27
#define CLASS protocol
28

29
using namespace std::placeholders;
30

31
// Properties.
32
// ----------------------------------------------------------------------------
33

34
query& protocol::archive() const NOEXCEPT
50,364 ✔
35
{
36
    return session_->archive();
50,364 ✔
37
}
38

39
const node::configuration& protocol::node_config() const NOEXCEPT
1 ✔
40
{
41
    return session_->node_config();
1 ✔
42
}
43

44
const system::settings& protocol::system_settings() const NOEXCEPT
35 ✔
45
{
46
    return session_->system_settings();
35 ✔
47
}
48

49
const database::settings& protocol::database_settings() const NOEXCEPT
4 ✔
50
{
51
    return session_->database_settings();
4 ✔
52
}
53

54
////const network::settings& protocol::network_settings() const NOEXCEPT
55
////{
56
////    return session_->network_settings();
57
////}
58

59
const node::settings& protocol::node_settings() const NOEXCEPT
60 ✔
60
{
61
    return session_->node_settings();
60 ✔
62
}
63

64
bool protocol::is_current_chain(bool confirmed) const NOEXCEPT
170 ✔
65
{
66
    return session_->is_current_chain(confirmed);
170 ✔
67
}
68

69
bool protocol::is_current_time(uint32_t timestamp) const NOEXCEPT
13 ✔
70
{
71
    return session_->is_current_time(timestamp);
13 ✔
72
}
73

74
uint64_t protocol::minimum_fee_rate() const NOEXCEPT
55 ✔
75
{
76
    return is_current_chain(true) ? node_settings().pool.minimum_fee_rate_() :
55 ✔
77
        system_settings().max_money();
3 ✔
78
}
79

80
time_t protocol::start_time() const NOEXCEPT
1 ✔
81
{
82
    return session_->start_time();
1 ✔
83
}
84

85
size_t protocol::channel_count() const NOEXCEPT
1 ✔
86
{
87
    return session_->channel_count();
1 ✔
88
}
89

90
size_t protocol::inbound_channel_count() const NOEXCEPT
1 ✔
91
{
92
    return session_->inbound_channel_count();
1 ✔
93
}
94

95
// Methods.
96
// ----------------------------------------------------------------------------
97

NEW
98
void protocol::get_template(template_handler&& handler) NOEXCEPT
×
99
{
NEW
100
    session_->get_template(std::move(handler));
×
NEW
101
}
×
102

103
void protocol::estimate(size_t target, estimate_mode mode,
1 ✔
104
    estimate_handler&& handler) NOEXCEPT
105
{
106
    session_->estimate(target, mode, std::move(handler));
1 ✔
107
}
1 ✔
108

109
// Events subscription.
110
// ----------------------------------------------------------------------------
111

112
size_t protocol::address_count() const NOEXCEPT
1 ✔
113
{
114
    return session_->address_count();
1 ✔
115
}
116

117
void protocol::connect(const network::config::endpoint& endpoint) NOEXCEPT
1 ✔
118
{
119
    session_->connect(endpoint);
1 ✔
120
}
1 ✔
121

122
void protocol::connect(const network::config::endpoint& endpoint,
1 ✔
123
    network::net::channel_notifier&& handler) NOEXCEPT
124
{
125
    session_->connect(endpoint, std::move(handler));
1 ✔
126
}
1 ✔
127

128
bool protocol::suspended() const NOEXCEPT
2 ✔
129
{
130
    return session_->suspended();
2 ✔
131
}
132

133
void protocol::suspend(const code& ec) NOEXCEPT
1 ✔
134
{
135
    session_->suspend(ec);
1 ✔
136
}
1 ✔
137

138
bool protocol::resume() NOEXCEPT
1 ✔
139
{
140
    return session_->resume();
1 ✔
141
}
142

143
// Organizers.
144
// ----------------------------------------------------------------------------
145

146
void protocol::organize(const system::chain::header::cptr& header,
1 ✔
147
    organize_handler&& handler) NOEXCEPT
148
{
149
    session_->organize(header, std::move(handler));
1 ✔
150
}
1 ✔
151

152
void protocol::organize(const system::chain::header::cptr& header,
6,010 ✔
153
    bool milestone, organize_handler&& handler) NOEXCEPT
154
{
155
    session_->organize(header, milestone, std::move(handler));
6,010 ✔
156
}
6,010 ✔
157

158
void protocol::organize_compact(const system::chain::header::cptr& header,
6 ✔
159
    organize_handler&& handler) NOEXCEPT
160
{
161
    session_->organize_compact(header, std::move(handler));
6 ✔
162
}
6 ✔
163

164
void protocol::prioritize(const system::hash_digest& hash,
1 ✔
165
    organize_handler&& handler) NOEXCEPT
166
{
167
    session_->prioritize(hash, std::move(handler));
1 ✔
168
}
1 ✔
169

170
void protocol::get_minimum_work(work_handler&& handler) NOEXCEPT
66 ✔
171
{
172
    session_->get_minimum_work(std::move(handler));
66 ✔
173
}
66 ✔
174

UNCOV
175
void protocol::submit(const system::chain::transactions_cptr& txs, bool test,
×
176
    submit_handler&& handler) NOEXCEPT
177
{
UNCOV
178
    session_->submit(txs, test, std::move(handler));
×
UNCOV
179
}
×
180

181
void protocol::submit_announced(const system::chain::transactions_cptr& txs,
24 ✔
182
    submit_handler&& handler) NOEXCEPT
183
{
184
    session_->submit_announced(txs, std::move(handler));
24 ✔
185
}
24 ✔
186

187
void protocol::submit_compact(const system::chain::transactions_cptr& txs,
3 ✔
188
    const database::tx_links& links, const database::header_link& link,
189
    submit_handler&& handler) NOEXCEPT
190
{
191
    session_->submit_compact(txs, links, link, std::move(handler));
3 ✔
192
}
3 ✔
193

194
bool protocol::archive_block(code& ec,
5 ✔
195
    const system::chain::view::block::cptr& block,
196
    const database::header_link& link, bool strong, bool bypass, size_t height,
197
    bool prune, network::result_handler&& handler) NOEXCEPT
198
{
199
    return session_->archive_block(ec, block, link, strong, bypass, height,
5 ✔
200
        prune, std::move(handler));
5 ✔
201
}
202

203
void protocol::subscribe_chase(event_notifier&& handler) NOEXCEPT
452 ✔
204
{
205
    // This is a shared instance multiply-derived from network::protocol.
206
    const auto self = dynamic_cast<network::protocol&>(*this)
×
207
        .shared_from_sibling<node::protocol, network::protocol>();
452 ✔
208

209
    event_completer completer = std::bind(&protocol::handle_subscribed, self,
904 ✔
210
        _1, _2);
452 ✔
211

212
    session_->subscribe_chase(std::move(handler),
452 ✔
213
        std::bind(&protocol::handle_subscribe,
452 ✔
214
            self, _1, _2, std::move(completer)));
452 ✔
215
}
452 ✔
216

217
// private
218
void protocol::handle_subscribe(const code& ec, object_key key,
452 ✔
219
    const event_completer& complete) NOEXCEPT
220
{
221
    // The key member is protected by one event subscription per protocol.
222
    BC_ASSERT_MSG(is_zero(key_), "unsafe access");
452 ✔
223

224
    // Protocol stop is thread safe.
225
    if (ec)
452 ✔
226
    {
227
        channel_->stop(ec);
4 ✔
228
        return;
4 ✔
229
    }
230

231
    key_ = key;
448 ✔
232
    complete(ec, key_);
448 ✔
233
}
234

235
void protocol::handle_subscribed(const code& ec, object_key key) NOEXCEPT
448 ✔
236
{
237
    // This is a shared instance multiply-derived from network::protocol.
238
    const auto self = dynamic_cast<network::protocol&>(*this)
×
239
        .shared_from_sibling<node::protocol, network::protocol>();
448 ✔
240

241
    network::io::post(channel_->strand(),
448 ✔
242
        std::bind(&protocol::subscribed, self, ec, key));
896 ✔
243
}
448 ✔
244

245
void protocol::subscribed(const code& ec, object_key) NOEXCEPT
396 ✔
246
{
247
    BC_ASSERT(channel_->stranded());
396 ✔
248

249
    // Unsubscriber race is ok.
250
    if (channel_->stopped() || ec)
396 ✔
251
        unsubscribe_chase();
×
252
}
396 ✔
253

254
// As this has no completion handler resubscription is not allowed.
255
void protocol::unsubscribe_chase() NOEXCEPT
578 ✔
256
{
257
    session_->unsubscribe_chase(key_);
578 ✔
258
    key_ = {};
578 ✔
259
}
578 ✔
260

261
object_key protocol::events_key() const NOEXCEPT
27 ✔
262
{
263
    return key_;
27 ✔
264
}
265

266
} // namespace node
267
} // namespace libbitcoin
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc