Skip to content

Commit

Permalink
interfaces: Add helper function for wallet on pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
fjahr committed Jan 5, 2025
1 parent 228aba2 commit 42d5d53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ class Chain
//! Check if any block has been pruned.
virtual bool havePruned() = 0;

//! Get the current prune height.
virtual std::optional<int> getPruneHeight() = 0;

//! Check if the node is ready to broadcast transactions.
virtual bool isReadyToBroadcast() = 0;

Expand Down
6 changes: 6 additions & 0 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <policy/settings.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <rpc/blockchain.h>
#include <rpc/protocol.h>
#include <rpc/server.h>
#include <support/allocators/secure.h>
Expand Down Expand Up @@ -770,6 +771,11 @@ class ChainImpl : public Chain
LOCK(::cs_main);
return chainman().m_blockman.m_have_pruned;
}
std::optional<int> getPruneHeight() override
{
LOCK(chainman().GetMutex());
return GetPruneHeight(chainman().m_blockman, chainman().ActiveChain());
}
bool isReadyToBroadcast() override { return !chainman().m_blockman.LoadingBlocks() && !isInitialBlockDownload(); }
bool isInitialBlockDownload() override
{
Expand Down

0 comments on commit 42d5d53

Please sign in to comment.