Skip to content

Commit 4a6b1f3

Browse files
committed
Expose AcceptBlockHeader through main.h
1 parent 93566e0 commit 4a6b1f3

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3649,7 +3649,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, const Co
36493649
return true;
36503650
}
36513651

3652-
static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex=NULL)
3652+
static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex)
36533653
{
36543654
AssertLockHeld(cs_main);
36553655
// Check for duplicate
@@ -3698,6 +3698,21 @@ static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state
36983698
return true;
36993699
}
37003700

3701+
// Exposed wrapper for AcceptBlockHeader
3702+
bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex)
3703+
{
3704+
{
3705+
LOCK(cs_main);
3706+
for (const CBlockHeader& header : headers) {
3707+
if (!AcceptBlockHeader(header, state, chainparams, ppindex)) {
3708+
return false;
3709+
}
3710+
}
3711+
}
3712+
NotifyHeaderTip();
3713+
return true;
3714+
}
3715+
37013716
/** Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
37023717
static bool AcceptBlock(const CBlock& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, const CDiskBlockPos* dbp, bool* fNewBlock)
37033718
{

src/main.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
230230
* @return True if state.IsValid()
231231
*/
232232
bool ProcessNewBlock(const CChainParams& chainparams, const CBlock* pblock, bool fForceProcessing, const CDiskBlockPos* dbp, bool* fNewBlock);
233+
234+
/**
235+
* Process incoming block headers.
236+
*
237+
* @param[in] block The block headers themselves
238+
* @param[out] state This may be set to an Error state if any error occurred processing them
239+
* @param[in] chainparams The params for the chain we want to connect to
240+
* @param[out] ppindex If set, the pointer will be set to point to the last new block index object for the given headers
241+
*/
242+
bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex=NULL);
243+
233244
/** Check whether enough disk space is available for an incoming block */
234245
bool CheckDiskSpace(uint64_t nAdditionalBytes = 0);
235246
/** Open a block file (blk?????.dat) */

0 commit comments

Comments
 (0)