Skip to content

Commit

Permalink
ignore txpool warning(sync from FISCO-BCOS#3845)
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyShi22 committed Aug 24, 2023
1 parent 5a24d08 commit d399f7c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bcos-tool/bcos-tool/LedgerConfigFetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using namespace bcos::consensus;
using namespace bcos::tool;
using namespace bcos::ledger;

void LedgerConfigFetcher::fetchBlockNumberAndHash()
void LedgerConfigFetcher::fetchBlockNumber()
{
std::promise<std::pair<Error::Ptr, BlockNumber>> blockNumberPromise;
m_ledger->asyncGetBlockNumber([&blockNumberPromise](Error::Ptr _error, BlockNumber _number) {
Expand All @@ -51,6 +51,12 @@ void LedgerConfigFetcher::fetchBlockNumberAndHash()
m_ledgerConfig->setBlockNumber(blockNumber);
TOOL_LOG(INFO) << LOG_DESC("LedgerConfigFetcher: fetchBlockNumber success")
<< LOG_KV("blockNumber", blockNumber);
}

void LedgerConfigFetcher::fetchBlockNumberAndHash()
{
fetchBlockNumber();
auto blockNumber = m_ledgerConfig->blockNumber();
// fetch blockHash
auto hash = fetchBlockHash(blockNumber);
TOOL_LOG(INFO) << LOG_DESC("LedgerConfigFetcher: fetchBlockHash success")
Expand Down
1 change: 1 addition & 0 deletions bcos-tool/bcos-tool/LedgerConfigFetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class LedgerConfigFetcher : public std::enable_shared_from_this<LedgerConfigFetc

virtual ~LedgerConfigFetcher() {}

virtual void fetchBlockNumber();
virtual void fetchBlockNumberAndHash();
virtual void fetchConsensusNodeList();
virtual void fetchObserverNodeList();
Expand Down
15 changes: 15 additions & 0 deletions bcos-txpool/bcos-txpool/TxPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,21 @@ void TxPool::initSendResponseHandler()
void TxPool::storeVerifiedBlock(bcos::protocol::Block::Ptr _block)
{
auto blockHeader = _block->blockHeader();

// return if block has been committed
auto ledgerConfigFetcher = std::make_shared<LedgerConfigFetcher>(m_config->ledger());
TXPOOL_LOG(INFO) << LOG_DESC("storeVerifiedBlock fetch block number from LedgerConfig");
ledgerConfigFetcher->fetchBlockNumber();
auto committedBlockNumber = ledgerConfigFetcher->ledgerConfig()->blockNumber();
if (blockHeader->number() <= committedBlockNumber)
{
TXPOOL_LOG(INFO) << LOG_DESC("storeVerifiedBlock, block already committed")
<< LOG_KV("consNum", blockHeader->number())
<< LOG_KV("hash", blockHeader->hash().abridged())
<< LOG_KV("committedNum", committedBlockNumber);
return;
}

TXPOOL_LOG(INFO) << LOG_DESC("storeVerifiedBlock") << LOG_KV("consNum", blockHeader->number())
<< LOG_KV("hash", blockHeader->hash().abridged())
<< LOG_KV("txsSize", _block->transactionsHashSize());
Expand Down

0 comments on commit d399f7c

Please sign in to comment.