mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge c07935bcf5 into merged_master (Bitcoin PR #28960)
This commit is contained in:
commit
81a17ea31a
40 changed files with 368 additions and 291 deletions
|
|
@ -20,6 +20,7 @@ class BanMan;
|
|||
class BaseIndex;
|
||||
class CBlockPolicyEstimator;
|
||||
class CConnman;
|
||||
class ValidationSignals;
|
||||
class CScheduler;
|
||||
class CTxMemPool;
|
||||
class ChainstateManager;
|
||||
|
|
@ -71,7 +72,10 @@ struct NodeContext {
|
|||
std::unique_ptr<CScheduler> scheduler;
|
||||
std::unique_ptr<CScheduler> reverification_scheduler;
|
||||
std::function<void()> rpc_interruption_point = [] {};
|
||||
//! Issues blocking calls about sync status, errors and warnings
|
||||
std::unique_ptr<KernelNotifications> notifications;
|
||||
//! Issues calls about blocks and transactions
|
||||
std::unique_ptr<ValidationSignals> validation_signals;
|
||||
std::atomic<int> exit_status{EXIT_SUCCESS};
|
||||
|
||||
//! Declare default constructor and destructor that are not inline, so code
|
||||
|
|
|
|||
|
|
@ -461,19 +461,20 @@ public:
|
|||
class NotificationsHandlerImpl : public Handler
|
||||
{
|
||||
public:
|
||||
explicit NotificationsHandlerImpl(std::shared_ptr<Chain::Notifications> notifications)
|
||||
: m_proxy(std::make_shared<NotificationsProxy>(std::move(notifications)))
|
||||
explicit NotificationsHandlerImpl(ValidationSignals& signals, std::shared_ptr<Chain::Notifications> notifications)
|
||||
: m_signals{signals}, m_proxy{std::make_shared<NotificationsProxy>(std::move(notifications))}
|
||||
{
|
||||
RegisterSharedValidationInterface(m_proxy);
|
||||
m_signals.RegisterSharedValidationInterface(m_proxy);
|
||||
}
|
||||
~NotificationsHandlerImpl() override { disconnect(); }
|
||||
void disconnect() override
|
||||
{
|
||||
if (m_proxy) {
|
||||
UnregisterSharedValidationInterface(m_proxy);
|
||||
m_signals.UnregisterSharedValidationInterface(m_proxy);
|
||||
m_proxy.reset();
|
||||
}
|
||||
}
|
||||
ValidationSignals& m_signals;
|
||||
std::shared_ptr<NotificationsProxy> m_proxy;
|
||||
};
|
||||
|
||||
|
|
@ -763,12 +764,12 @@ public:
|
|||
}
|
||||
std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) override
|
||||
{
|
||||
return std::make_unique<NotificationsHandlerImpl>(std::move(notifications));
|
||||
return std::make_unique<NotificationsHandlerImpl>(validation_signals(), std::move(notifications));
|
||||
}
|
||||
void waitForNotificationsIfTipChanged(const uint256& old_tip) override
|
||||
{
|
||||
if (!old_tip.IsNull() && old_tip == WITH_LOCK(::cs_main, return chainman().ActiveChain().Tip()->GetBlockHash())) return;
|
||||
SyncWithValidationInterfaceQueue();
|
||||
validation_signals().SyncWithValidationInterfaceQueue();
|
||||
}
|
||||
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
|
||||
{
|
||||
|
|
@ -841,6 +842,7 @@ public:
|
|||
NodeContext* context() override { return &m_node; }
|
||||
ArgsManager& args() { return *Assert(m_node.args); }
|
||||
ChainstateManager& chainman() { return *Assert(m_node.chainman); }
|
||||
ValidationSignals& validation_signals() { return *Assert(m_node.validation_signals); }
|
||||
NodeContext& m_node;
|
||||
};
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
|||
node.mempool->AddUnbroadcastTx(txid);
|
||||
}
|
||||
|
||||
if (wait_callback) {
|
||||
if (wait_callback && node.validation_signals) {
|
||||
// For transactions broadcast from outside the wallet, make sure
|
||||
// that the wallet has been notified of the transaction before
|
||||
// continuing.
|
||||
|
|
@ -101,7 +101,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
|||
// with a transaction to/from their wallet, immediately call some
|
||||
// wallet RPC, and get a stale result because callbacks have not
|
||||
// yet been processed.
|
||||
CallFunctionInValidationInterfaceQueue([&promise] {
|
||||
node.validation_signals->CallFunctionInValidationInterfaceQueue([&promise] {
|
||||
promise.set_value();
|
||||
});
|
||||
callback_set = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue