Blocks weren't being added to unchecked if a containing block was in the gap_cache.
This commit is contained in:
parent
b219fc3294
commit
d26c2474d7
3 changed files with 11 additions and 11 deletions
|
@ -7,8 +7,7 @@ TEST (gap_cache, add_new)
|
|||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1 (0, 1, 2, rai::keypair ().prv, 4, 5);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
cache.add (transaction, rai::send_block (block1), block1.previous ());
|
||||
ASSERT_NE (system.nodes [0]->store.unchecked_end (), system.nodes [0]->store.unchecked_begin (transaction, block1.previous ()));
|
||||
cache.add (transaction, rai::send_block (block1));
|
||||
}
|
||||
|
||||
TEST (gap_cache, add_existing)
|
||||
|
@ -17,12 +16,12 @@ TEST (gap_cache, add_existing)
|
|||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1 (0, 1, 2, rai::keypair ().prv, 4, 5);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
cache.add (transaction, block1, block1.previous ());
|
||||
cache.add (transaction, block1);
|
||||
auto existing1 (cache.blocks.get <1> ().find (block1.hash ()));
|
||||
ASSERT_NE (cache.blocks.get <1> ().end (), existing1);
|
||||
auto arrival (existing1->arrival);
|
||||
while (arrival == std::chrono::system_clock::now ());
|
||||
cache.add (transaction, block1, block1.previous ());
|
||||
cache.add (transaction, block1);
|
||||
ASSERT_EQ (1, cache.blocks.size ());
|
||||
auto existing2 (cache.blocks.get <1> ().find (block1.hash ()));
|
||||
ASSERT_NE (cache.blocks.get <1> ().end (), existing2);
|
||||
|
@ -35,13 +34,13 @@ TEST (gap_cache, comparison)
|
|||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1 (1, 0, 2, rai::keypair ().prv, 4, 5);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
cache.add (transaction, block1, block1.previous ());
|
||||
cache.add (transaction, block1);
|
||||
auto existing1 (cache.blocks.get <1> ().find (block1.hash ()));
|
||||
ASSERT_NE (cache.blocks.get <1> ().end (), existing1);
|
||||
auto arrival (existing1->arrival);
|
||||
while (std::chrono::system_clock::now () == arrival);
|
||||
rai::send_block block3 (0, 42, 1, rai::keypair ().prv, 3, 4);
|
||||
cache.add (transaction, block3, block3.previous ());
|
||||
cache.add (transaction, block3);
|
||||
ASSERT_EQ (2, cache.blocks.size ());
|
||||
auto existing2 (cache.blocks.get <1> ().find (block3.hash ()));
|
||||
ASSERT_NE (cache.blocks.get <1> ().end (), existing2);
|
||||
|
|
|
@ -1244,7 +1244,7 @@ node (node_a)
|
|||
{
|
||||
}
|
||||
|
||||
void rai::gap_cache::add (MDB_txn * transaction_a, rai::block const & block_a, rai::block_hash const & hash_a)
|
||||
void rai::gap_cache::add (MDB_txn * transaction_a, rai::block const & block_a)
|
||||
{
|
||||
auto hash (block_a.hash ());
|
||||
std::lock_guard <std::mutex> lock (mutex);
|
||||
|
@ -1258,7 +1258,6 @@ void rai::gap_cache::add (MDB_txn * transaction_a, rai::block const & block_a, r
|
|||
}
|
||||
else
|
||||
{
|
||||
node.store.unchecked_put (transaction_a, hash_a, block_a);
|
||||
blocks.insert ({std::chrono::system_clock::now (), hash, std::unique_ptr <rai::votes> (new rai::votes (block_a))});
|
||||
if (blocks.size () > max)
|
||||
{
|
||||
|
@ -1436,7 +1435,8 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Gap previous for: %1%") % block_a.hash ().to_string ());
|
||||
}
|
||||
gap_cache.add (transaction_a, block_a, block_a.previous ());
|
||||
store.unchecked_put (transaction_a, block_a.previous (), block_a);
|
||||
gap_cache.add (transaction_a, block_a);
|
||||
break;
|
||||
}
|
||||
case rai::process_result::gap_source:
|
||||
|
@ -1445,7 +1445,8 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Gap source for: %1%") % block_a.hash ().to_string ());
|
||||
}
|
||||
gap_cache.add (transaction_a, block_a, block_a.source ());
|
||||
store.unchecked_put (transaction_a, block_a.source (), block_a);
|
||||
gap_cache.add (transaction_a, block_a);
|
||||
break;
|
||||
}
|
||||
case rai::process_result::old:
|
||||
|
|
|
@ -130,7 +130,7 @@ class gap_cache
|
|||
{
|
||||
public:
|
||||
gap_cache (rai::node &);
|
||||
void add (MDB_txn *, rai::block const &, rai::block_hash const &);
|
||||
void add (MDB_txn *, rai::block const &);
|
||||
void vote (rai::vote const &);
|
||||
rai::uint128_t bootstrap_threshold (MDB_txn *);
|
||||
void purge_old ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue