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

libbitcoin / libbitcoin-node / 46189728508

28 Nov 2026 09:05PM UTC coverage: 89.445% (-0.1%) from 89.541%
46189728508

push

github

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

Query unconfirmed totals on tx chaser.

8 of 12 new or added lines in 4 files covered. (66.67%)

44 existing lines in 5 files now uncovered.

5220 of 5836 relevant lines covered (89.44%)

4347.36 hits per line

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

74.8
/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,371 ✔
35
{
36
    return session_->archive();
50,371 ✔
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
41 ✔
45
{
46
    return session_->system_settings();
41 ✔
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
11 ✔
60
{
61
    return session_->node_settings();
11 ✔
62
}
63

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

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

74
uint64_t protocol::minimum_fee_rate() const NOEXCEPT
×
75
{
76
    return is_current_chain(true) ? node_settings().pool.minimum_fee_rate_() :
×
77
        system_settings().max_money();
×
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

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

103
void protocol::demand_template(bool demand) NOEXCEPT
×
104
{
105
    session_->demand_template(demand);
×
106
}
×
107

108
uint64_t protocol::template_generation() const NOEXCEPT
×
109
{
110
    return session_->template_generation();
×
111
}
112

113
void protocol::estimate(size_t target, estimate_mode mode,
1 ✔
114
    estimate_handler&& handler) NOEXCEPT
115
{
116
    session_->estimate(target, mode, std::move(handler));
1 ✔
117
}
1 ✔
118

119
void protocol::get_confirmable_txs(confirmable_txs_handler&& handler) NOEXCEPT
×
120
{
121
    session_->get_confirmable_txs(std::move(handler));
×
122
}
×
123

124
void protocol::get_confirmable_fees(confirmable_fees_handler&& handler) NOEXCEPT
×
125
{
126
    session_->get_confirmable_fees(std::move(handler));
×
127
}
×
128

NEW
129
void protocol::get_unconfirmed_totals(const database::pool_receipts& receipts,
×
130
    unconfirmed_totals_handler&& handler) NOEXCEPT
131
{
NEW
132
    session_->get_unconfirmed_totals(receipts, std::move(handler));
×
UNCOV
133
}
×
134

135
// Events subscription.
136
// ----------------------------------------------------------------------------
137

138
size_t protocol::address_count() const NOEXCEPT
1 ✔
139
{
140
    return session_->address_count();
1 ✔
141
}
142

143
void protocol::connect(const network::config::endpoint& endpoint) NOEXCEPT
1 ✔
144
{
145
    session_->connect(endpoint);
1 ✔
146
}
1 ✔
147

148
void protocol::connect(const network::config::endpoint& endpoint,
1 ✔
149
    network::net::channel_notifier&& handler) NOEXCEPT
150
{
151
    session_->connect(endpoint, std::move(handler));
1 ✔
152
}
1 ✔
153

154
bool protocol::suspended() const NOEXCEPT
2 ✔
155
{
156
    return session_->suspended();
2 ✔
157
}
158

159
void protocol::suspend(const code& ec) NOEXCEPT
1 ✔
160
{
161
    session_->suspend(ec);
1 ✔
162
}
1 ✔
163

164
bool protocol::resume() NOEXCEPT
1 ✔
165
{
166
    return session_->resume();
1 ✔
167
}
168

169
// Organizers.
170
// ----------------------------------------------------------------------------
171

172
void protocol::organize(const system::chain::header::cptr& header,
1 ✔
173
    organize_handler&& handler) NOEXCEPT
174
{
175
    session_->organize(header, std::move(handler));
1 ✔
176
}
1 ✔
177

178
void protocol::organize(const system::chain::header::cptr& header,
6,010 ✔
179
    bool milestone, organize_handler&& handler) NOEXCEPT
180
{
181
    session_->organize(header, milestone, std::move(handler));
6,010 ✔
182
}
6,010 ✔
183

184
void protocol::organize_compact(const system::chain::header::cptr& header,
10 ✔
185
    organize_handler&& handler) NOEXCEPT
186
{
187
    session_->organize_compact(header, std::move(handler));
10 ✔
188
}
10 ✔
189

UNCOV
190
void protocol::organize_submitted(const system::chain::header::cptr& header,
×
191
    bool milestone, organize_handler&& handler) NOEXCEPT
192
{
UNCOV
193
    session_->organize_submitted(header, milestone, std::move(handler));
×
UNCOV
194
}
×
195

196
void protocol::prioritize(const system::hash_digest& hash,
1 ✔
197
    organize_handler&& handler) NOEXCEPT
198
{
199
    session_->prioritize(hash, std::move(handler));
1 ✔
200
}
1 ✔
201

202
void protocol::get_minimum_work(work_handler&& handler) NOEXCEPT
79 ✔
203
{
204
    session_->get_minimum_work(std::move(handler));
79 ✔
205
}
79 ✔
206

UNCOV
207
void protocol::submit(const system::chain::transactions_cptr& txs, bool test,
×
208
    submit_handler&& handler) NOEXCEPT
209
{
UNCOV
210
    session_->submit(txs, test, std::move(handler));
×
UNCOV
211
}
×
212

213
void protocol::submit_announced(const system::chain::transactions_cptr& txs,
27 ✔
214
    size_t slot, submit_handler&& handler) NOEXCEPT
215
{
216
    session_->submit_announced(txs, slot, std::move(handler));
27 ✔
217
}
27 ✔
218

219
void protocol::submit_compact(const system::chain::transactions_cptr& txs,
4 ✔
220
    const database::tx_links& links, const database::header_link& link,
221
    submit_handler&& handler) NOEXCEPT
222
{
223
    session_->submit_compact(txs, links, link, std::move(handler));
4 ✔
224
}
4 ✔
225

226
bool protocol::archive_block(code& ec,
6 ✔
227
    const system::chain::view::block::cptr& block,
228
    const database::header_link& link, bool strong, bool bypass, size_t height,
229
    bool prune, network::result_handler&& handler) NOEXCEPT
230
{
231
    return session_->archive_block(ec, block, link, strong, bypass, height,
6 ✔
232
        prune, std::move(handler));
6 ✔
233
}
234

235
void protocol::subscribe_chase(event_notifier&& handler) NOEXCEPT
541 ✔
236
{
237
    // This is a shared instance multiply-derived from network::protocol.
UNCOV
238
    const auto self = dynamic_cast<network::protocol&>(*this)
×
239
        .shared_from_sibling<node::protocol, network::protocol>();
541 ✔
240

241
    event_completer completer = std::bind(&protocol::handle_subscribed, self,
1,082 ✔
242
        _1, _2);
541 ✔
243

244
    session_->subscribe_chase(std::move(handler),
541 ✔
245
        std::bind(&protocol::handle_subscribe,
541 ✔
246
            self, _1, _2, std::move(completer)));
541 ✔
247
}
541 ✔
248

249
// private
250
void protocol::handle_subscribe(const code& ec, object_key key,
541 ✔
251
    const event_completer& complete) NOEXCEPT
252
{
253
    // The key member is protected by one event subscription per protocol.
254
    BC_ASSERT_MSG(is_zero(key_), "unsafe access");
541 ✔
255

256
    // Protocol stop is thread safe.
257
    if (ec)
541 ✔
258
    {
259
        channel_->stop(ec);
4 ✔
260
        return;
4 ✔
261
    }
262

263
    key_ = key;
537 ✔
264
    complete(ec, key_);
537 ✔
265
}
266

267
void protocol::handle_subscribed(const code& ec, object_key key) NOEXCEPT
537 ✔
268
{
269
    // This is a shared instance multiply-derived from network::protocol.
UNCOV
270
    const auto self = dynamic_cast<network::protocol&>(*this)
×
271
        .shared_from_sibling<node::protocol, network::protocol>();
537 ✔
272

273
    network::io::post(channel_->strand(),
537 ✔
274
        std::bind(&protocol::subscribed, self, ec, key));
1,074 ✔
275
}
537 ✔
276

277
void protocol::subscribed(const code& ec, object_key) NOEXCEPT
384 ✔
278
{
279
    BC_ASSERT(channel_->stranded());
384 ✔
280

281
    // Unsubscriber race is ok.
282
    if (channel_->stopped() || ec)
384 ✔
UNCOV
283
        unsubscribe_chase();
×
284
}
384 ✔
285

286
// As this has no completion handler resubscription is not allowed.
287
void protocol::unsubscribe_chase() NOEXCEPT
696 ✔
288
{
289
    session_->unsubscribe_chase(key_);
696 ✔
290
    key_ = {};
696 ✔
291
}
696 ✔
292

293
object_key protocol::events_key() const NOEXCEPT
36 ✔
294
{
295
    return key_;
36 ✔
296
}
297

298
void protocol::notify(const code& ec, event_value value) const NOEXCEPT
38 ✔
299
{
300
    session_->notify(ec, value);
38 ✔
301
}
38 ✔
302

UNCOV
303
void protocol::notify_one(object_key key, const code& ec,
×
304
    event_value value) const NOEXCEPT
305
{
UNCOV
306
    session_->notify_one(key, ec, value);
×
UNCOV
307
}
×
308

309
} // namespace node
310
} // 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