Skip to content

Commit 7db88e9

Browse files
committed
Fix thread safety on electrum fee estimate completion.
1 parent e9848f7 commit 7db88e9

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

include/bitcoin/server/protocols/protocol_electrum.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class BCS_API protocol_electrum
257257
void complete_get_mempool(const code& ec, const histories& histories) NOEXCEPT;
258258
void complete_list_unspent(const code& ec, const unspents& unspents) NOEXCEPT;
259259

260+
void handle_estimate_fee(const code& ec, uint64_t fee) NOEXCEPT;
260261
void complete_estimate_fee(const code& ec, uint64_t fee) NOEXCEPT;
261262

262263
/// Notification event handlers.

src/protocols/electrum/protocol_electrum_fees.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ void protocol_electrum::handle_blockchain_estimate_fee(const code& ec,
4646
rpc_interface::blockchain_estimate_fee, double number,
4747
const std::string& mode) NOEXCEPT
4848
{
49+
BC_ASSERT(stranded());
50+
4951
if (stopped(ec))
5052
return;
5153

@@ -75,12 +77,20 @@ void protocol_electrum::handle_blockchain_estimate_fee(const code& ec,
7577
return;
7678
}
7779

78-
estimate(target, mode_, BIND(complete_estimate_fee, _1, _2));
80+
estimate(target, mode_, BIND(handle_estimate_fee, _1, _2));
81+
}
82+
83+
void protocol_electrum::handle_estimate_fee(const code& ec,
84+
uint64_t fee) NOEXCEPT
85+
{
86+
POST(complete_estimate_fee, ec, fee);
7987
}
8088

8189
void protocol_electrum::complete_estimate_fee(const code& ec,
8290
uint64_t fee) NOEXCEPT
8391
{
92+
BC_ASSERT(stranded());
93+
8494
if (stopped())
8595
return;
8696

@@ -103,6 +113,8 @@ void protocol_electrum::complete_estimate_fee(const code& ec,
103113
void protocol_electrum::handle_blockchain_relay_fee(const code& ec,
104114
rpc_interface::blockchain_relay_fee) NOEXCEPT
105115
{
116+
BC_ASSERT(stranded());
117+
106118
if (stopped(ec))
107119
return;
108120

0 commit comments

Comments
 (0)