fixed blockfilter_index_tests
This commit is contained in:
parent
cc037fafc4
commit
13a737de71
3 changed files with 15 additions and 9 deletions
|
@ -331,7 +331,7 @@ public:
|
||||||
// FIXME: update heights and add activation tests
|
// FIXME: update heights and add activation tests
|
||||||
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
|
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
|
||||||
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
|
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
|
||||||
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
|
consensus.CSVHeight = 0; // CSV activated on regtest (Used in rpc activation tests)
|
||||||
consensus.SegwitHeight = 150; // SEGWIT is always activated on regtest unless overridden
|
consensus.SegwitHeight = 150; // SEGWIT is always activated on regtest unless overridden
|
||||||
consensus.MinBIP9WarningHeight = 294;
|
consensus.MinBIP9WarningHeight = 294;
|
||||||
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||||
|
|
|
@ -60,7 +60,10 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
|
||||||
|
|
||||||
bool BlockFilterIndex::Init()
|
bool BlockFilterIndex::Init()
|
||||||
{
|
{
|
||||||
m_db->ReadFilePos(m_next_filter_pos);
|
if (!m_db->ReadFilePos(m_next_filter_pos)) {
|
||||||
|
m_next_filter_pos.nFile = 0;
|
||||||
|
m_next_filter_pos.nPos = 0;
|
||||||
|
}
|
||||||
return BaseIndex::Init();
|
return BaseIndex::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +178,8 @@ bool BlockFilterIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex
|
||||||
BlockFilter filter(m_filter_type, block, block_undo);
|
BlockFilter filter(m_filter_type, block, block_undo);
|
||||||
|
|
||||||
size_t bytes_written = WriteFilterToDisk(m_next_filter_pos, filter);
|
size_t bytes_written = WriteFilterToDisk(m_next_filter_pos, filter);
|
||||||
if (bytes_written == 0) return false;
|
if (bytes_written == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
(*m_db) << "INSERT INTO block VALUES(?, ?, ?, ?, ?, ?)"
|
(*m_db) << "INSERT INTO block VALUES(?, ?, ?, ?, ?, ?)"
|
||||||
<< pindex->nHeight
|
<< pindex->nHeight
|
||||||
|
@ -185,7 +189,7 @@ bool BlockFilterIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex
|
||||||
<< m_next_filter_pos.nFile
|
<< m_next_filter_pos.nFile
|
||||||
<< m_next_filter_pos.nPos;
|
<< m_next_filter_pos.nPos;
|
||||||
|
|
||||||
if (!(m_db->rows_modified() > 0)) {
|
if (m_db->rows_modified() <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,10 +197,11 @@ bool BlockFilterIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CopyHeightIndexToHashIndex(sqlite::database& db,
|
static bool CopyHeightIndexToHashIndex(sqlite::database& db, int start_height, int stop_height)
|
||||||
int start_height, int stop_height)
|
|
||||||
{
|
{
|
||||||
db << "UPDATE block SET height = NULL WHERE height >= ? and height <= ?"
|
if (start_height > stop_height)
|
||||||
|
return true;
|
||||||
|
db << "UPDATE block SET height = NULL WHERE height BETWEEN ? AND ?"
|
||||||
<< start_height << stop_height;
|
<< start_height << stop_height;
|
||||||
return db.rows_modified() > 0;
|
return db.rows_modified() > 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,11 @@ static CBlock CreateBlock(const CBlockIndex* prev,
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);
|
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);
|
||||||
CBlock& block = pblocktemplate->block;
|
CBlock& block = pblocktemplate->block;
|
||||||
block.hashPrevBlock = prev->GetBlockHash();
|
block.hashPrevBlock = prev->GetBlockHash();
|
||||||
|
block.hashClaimTrie = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
|
||||||
block.nTime = prev->nTime + 1;
|
block.nTime = prev->nTime + 1;
|
||||||
|
|
||||||
// Replace mempool-selected txns with just coinbase plus passed-in txns:
|
// Replace mempool-selected txns with just coinbase plus passed-in txns:
|
||||||
block.vtx.resize(1);
|
block.vtx.resize(1); // coinbase TXN
|
||||||
for (const CMutableTransaction& tx : txns) {
|
for (const CMutableTransaction& tx : txns) {
|
||||||
block.vtx.push_back(MakeTransactionRef(tx));
|
block.vtx.push_back(MakeTransactionRef(tx));
|
||||||
}
|
}
|
||||||
|
@ -87,7 +88,7 @@ static CBlock CreateBlock(const CBlockIndex* prev,
|
||||||
unsigned int extraNonce = 0;
|
unsigned int extraNonce = 0;
|
||||||
IncrementExtraNonce(&block, prev, extraNonce);
|
IncrementExtraNonce(&block, prev, extraNonce);
|
||||||
|
|
||||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue