Overview
Next step is to add the Pop mempool support for the ALT blockchain. We should implement methods for submitting Pop payloads to the mempool, fetching payloads during the block mining and removing payloads after successfully submitting a block to the blockchain.
1. Implement mempool related methods in the pop_service.hpp and pop_service.cpp source files.
https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/vbk/pop_service.hpp
+
+
Represents ALT block body of POP-related info.
https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/vbk/pop_service.cpp
+{
+ AssertLockHeld(cs_main);
+ return GetPop().mempool->getPop();
+}
+
+{
+ AssertLockHeld(cs_main);
+ GetPop().mempool->removeAll(popData);
+}
+
+{
+ disconnected_popdata.push_back(popData);
+}
2. Add PopData during block mining.
Update CreateNewBlock()
in the miner.cpp.
https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/miner.cpp
#include <util/system.h>
#include <util/validation.h>
+#include <vbk/pop_service.hpp>
+#include <vbk/util.hpp>
method BlockAssembler::CreateNewBlock
+
+ if (chainparams.isPopActive(nHeight))
+ {
+ pblock->popData = VeriBlock::getPopData();
+ }
+
if (!pblock->popData.empty()) {
pblock->nVersion |= VeriBlock::POP_BLOCK_VERSION_BIT;
}
int64_t nTime1 = GetTimeMicros();
3. Remove PopData after successfully submitting to the blockchain.
Modify ConnectTip()
and DisconnectTip()
methods in the validation.cpp.
https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/validation.cpp
method CChainState::DisconnectTip
+
+ VeriBlock::addDisconnectedPopdata(block.popData);
+
m_chain.SetTip(pindexDelete->pprev);
UpdateTip(pindexDelete->pprev, chainparams);
method CChainState::ConnectTip
disconnectpool.removeForBlock(blockConnecting.vtx);
+
+
+ VeriBlock::removePayloadsFromMempool(blockConnecting.popData);
+
m_chain.SetTip(pindexNew);
UpdateTip(pindexNew, chainparams);