Replacing cloning with shared pointers.
This commit is contained in:
parent
0eacc16003
commit
b2bafeb432
20 changed files with 321 additions and 345 deletions
|
@ -724,13 +724,13 @@ TEST (vote, validate)
|
|||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (0, key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
rai::vote vote1 (key1.pub, key1.prv, 2, send1.clone ());
|
||||
auto send1 (std::make_shared <rai::send_block> (0, key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
rai::vote vote1 (key1.pub, key1.prv, 2, send1);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
ASSERT_EQ (rai::vote_result::vote, vote1.validate (transaction, store));
|
||||
vote1.signature.bytes [8] ^= 1;
|
||||
ASSERT_EQ (rai::vote_result::invalid, vote1.validate (transaction, store));
|
||||
rai::vote vote2 (key1.pub, key1.prv, 1, send1.clone ());
|
||||
rai::vote vote2 (key1.pub, key1.prv, 1, send1);
|
||||
ASSERT_EQ (rai::vote_result::replay, vote2.validate (transaction, store));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,19 +7,19 @@ TEST (conflicts, start_stop)
|
|||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (send1).code);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (*send1).code);
|
||||
ASSERT_EQ (0, node1.active.roots.size ());
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
ASSERT_EQ (1, node1.active.roots.size ());
|
||||
auto root1 (send1.root ());
|
||||
auto root1 (send1->root ());
|
||||
auto existing1 (node1.active.roots.find (root1));
|
||||
ASSERT_NE (node1.active.roots.end (), existing1);
|
||||
auto votes1 (existing1->election);
|
||||
|
@ -33,30 +33,30 @@ TEST (conflicts, add_existing)
|
|||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (send1).code);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (*send1).code);
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
rai::keypair key2;
|
||||
rai::send_block send2 (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
auto send2 (std::make_shared <rai::send_block> (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send2, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send2, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
ASSERT_EQ (1, node1.active.roots.size ());
|
||||
rai::vote vote1 (key2.pub, key2.prv, 0, send2.clone ());
|
||||
rai::vote vote1 (key2.pub, key2.prv, 0, send2);
|
||||
node1.active.vote (vote1);
|
||||
ASSERT_EQ (1, node1.active.roots.size ());
|
||||
auto votes1 (node1.active.roots.find (send2.root ())->election);
|
||||
auto votes1 (node1.active.roots.find (send2->root ())->election);
|
||||
ASSERT_NE (nullptr, votes1);
|
||||
ASSERT_EQ (2, votes1->votes.rep_votes.size ());
|
||||
ASSERT_NE (votes1->votes.rep_votes.end (), votes1->votes.rep_votes.find (key2.pub));
|
||||
|
@ -68,22 +68,22 @@ TEST (conflicts, add_two)
|
|||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (send1).code);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (*send1).code);
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
rai::keypair key2;
|
||||
rai::send_block send2 (send1.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (send2).code);
|
||||
auto send2 (std::make_shared <rai::send_block> (send1->hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (*send2).code);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send2, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send2, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
|
|
|
@ -5,25 +5,25 @@ TEST (gap_cache, add_new)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1 (0, 1, 2, rai::keypair ().prv, 4, 5);
|
||||
auto block1 (std::make_shared <rai::send_block> (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));
|
||||
cache.add (transaction, block1);
|
||||
}
|
||||
|
||||
TEST (gap_cache, add_existing)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1 (0, 1, 2, rai::keypair ().prv, 4, 5);
|
||||
auto block1 (std::make_shared <rai::send_block> (0, 1, 2, rai::keypair ().prv, 4, 5));
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
cache.add (transaction, block1);
|
||||
auto existing1 (cache.blocks.get <1> ().find (block1.hash ()));
|
||||
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);
|
||||
ASSERT_EQ (1, cache.blocks.size ());
|
||||
auto existing2 (cache.blocks.get <1> ().find (block1.hash ()));
|
||||
auto existing2 (cache.blocks.get <1> ().find (block1->hash ()));
|
||||
ASSERT_NE (cache.blocks.get <1> ().end (), existing2);
|
||||
ASSERT_GT (existing2->arrival, arrival);
|
||||
}
|
||||
|
@ -32,17 +32,17 @@ TEST (gap_cache, comparison)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1 (1, 0, 2, rai::keypair ().prv, 4, 5);
|
||||
auto block1 (std::make_shared <rai::send_block> (1, 0, 2, rai::keypair ().prv, 4, 5));
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
cache.add (transaction, block1);
|
||||
auto existing1 (cache.blocks.get <1> ().find (block1.hash ()));
|
||||
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);
|
||||
auto block3 (std::make_shared <rai::send_block> (0, 42, 1, rai::keypair ().prv, 3, 4));
|
||||
cache.add (transaction, block3);
|
||||
ASSERT_EQ (2, cache.blocks.size ());
|
||||
auto existing2 (cache.blocks.get <1> ().find (block3.hash ()));
|
||||
auto existing2 (cache.blocks.get <1> ().find (block3->hash ()));
|
||||
ASSERT_NE (cache.blocks.get <1> ().end (), existing2);
|
||||
ASSERT_GT (existing2->arrival, arrival);
|
||||
ASSERT_EQ (arrival, cache.blocks.get <1> ().begin ()->arrival);
|
||||
|
@ -53,7 +53,7 @@ TEST (gap_cache, gap_bootstrap)
|
|||
rai::system system (24000, 2);
|
||||
rai::block_hash latest (system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
rai::keypair key;
|
||||
rai::send_block send (latest, key.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (latest));
|
||||
auto send (std::make_shared <rai::send_block> (latest, key.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (latest)));
|
||||
{
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->process_receive_one (transaction, send).code);
|
||||
|
@ -79,9 +79,9 @@ TEST (gap_cache, two_dependencies)
|
|||
rai::system system (24000, 1);
|
||||
rai::keypair key;
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1 (genesis.hash (), key.pub, 1, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ()));
|
||||
rai::send_block send2 (send1.hash (), key.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
rai::open_block open (send1.hash (), key.pub, key.pub, key.prv, key.pub, system.work.generate (key.pub));
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key.pub, 1, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared <rai::send_block> (send1->hash (), key.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto open (std::make_shared <rai::open_block> (send1->hash (), key.pub, key.pub, key.prv, key.pub, system.work.generate (key.pub)));
|
||||
ASSERT_EQ (0, system.nodes [0]->gap_cache.blocks.size ());
|
||||
system.nodes [0]->process_receive_many (send2);
|
||||
ASSERT_EQ (1, system.nodes [0]->gap_cache.blocks.size ());
|
||||
|
@ -90,7 +90,7 @@ TEST (gap_cache, two_dependencies)
|
|||
system.nodes [0]->process_receive_many (send1);
|
||||
ASSERT_EQ (0, system.nodes [0]->gap_cache.blocks.size ());
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction, send1.hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction, send2.hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction, open.hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction, send1->hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction, send2->hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction, open->hash ()));
|
||||
}
|
||||
|
|
|
@ -721,32 +721,32 @@ TEST (votes, add_one)
|
|||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, send1).code);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, *send1).code);
|
||||
}
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
auto votes1 (node1.active.roots.find (send1.root ())->election);
|
||||
auto votes1 (node1.active.roots.find (send1->root ())->election);
|
||||
ASSERT_EQ (1, votes1->votes.rep_votes.size ());
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send1.clone ());
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send1);
|
||||
votes1->vote (vote1);
|
||||
rai::vote vote2 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 2, send1.clone ());
|
||||
rai::vote vote2 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 2, send1);
|
||||
votes1->vote (vote1);
|
||||
ASSERT_EQ (2, votes1->votes.rep_votes.size ());
|
||||
auto existing1 (votes1->votes.rep_votes.find (rai::test_genesis_key.pub));
|
||||
ASSERT_NE (votes1->votes.rep_votes.end (), existing1);
|
||||
ASSERT_EQ (send1, *existing1->second);
|
||||
ASSERT_EQ (*send1, *existing1->second);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
auto winner (node1.ledger.winner (transaction, votes1->votes));
|
||||
ASSERT_EQ (send1, *winner.second);
|
||||
ASSERT_EQ (*send1, *winner.second);
|
||||
ASSERT_EQ (rai::genesis_amount - 100, winner.first);
|
||||
}
|
||||
|
||||
|
@ -756,34 +756,34 @@ TEST (votes, add_two)
|
|||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, send1).code);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, *send1).code);
|
||||
}
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
auto votes1 (node1.active.roots.find (send1.root ())->election);
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send1.clone ());
|
||||
auto votes1 (node1.active.roots.find (send1->root ())->election);
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send1);
|
||||
votes1->vote (vote1);
|
||||
rai::keypair key2;
|
||||
rai::send_block send2 (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
rai::vote vote2 (key2.pub, key2.prv, 1, send2.clone ());
|
||||
auto send2 (std::make_shared <rai::send_block> (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
rai::vote vote2 (key2.pub, key2.prv, 1, send2);
|
||||
votes1->vote (vote2);
|
||||
ASSERT_EQ (3, votes1->votes.rep_votes.size ());
|
||||
ASSERT_NE (votes1->votes.rep_votes.end (), votes1->votes.rep_votes.find (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (send1, *votes1->votes.rep_votes [rai::test_genesis_key.pub]);
|
||||
ASSERT_EQ (*send1, *votes1->votes.rep_votes [rai::test_genesis_key.pub]);
|
||||
ASSERT_NE (votes1->votes.rep_votes.end (), votes1->votes.rep_votes.find (key2.pub));
|
||||
ASSERT_EQ (send2, *votes1->votes.rep_votes [key2.pub]);
|
||||
ASSERT_EQ (*send2, *votes1->votes.rep_votes [key2.pub]);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
auto winner (node1.ledger.winner (transaction, votes1->votes));
|
||||
ASSERT_EQ (send1, *winner.second);
|
||||
ASSERT_EQ (*send1, *winner.second);
|
||||
}
|
||||
|
||||
// Higher sequence numbers change the vote
|
||||
|
@ -793,32 +793,32 @@ TEST (votes, add_existing)
|
|||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, send1).code);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, *send1).code);
|
||||
}
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
auto votes1 (node1.active.roots.find (send1.root ())->election);
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send1.clone ());
|
||||
auto votes1 (node1.active.roots.find (send1->root ())->election);
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send1);
|
||||
votes1->vote (vote1);
|
||||
rai::keypair key2;
|
||||
rai::send_block send2 (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
rai::vote vote2 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 2, send2.clone ());
|
||||
auto send2 (std::make_shared <rai::send_block> (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
rai::vote vote2 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 2, send2);
|
||||
votes1->vote (vote2);
|
||||
ASSERT_EQ (2, votes1->votes.rep_votes.size ());
|
||||
ASSERT_NE (votes1->votes.rep_votes.end (), votes1->votes.rep_votes.find (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (send2, *votes1->votes.rep_votes [rai::test_genesis_key.pub]);
|
||||
ASSERT_EQ (*send2, *votes1->votes.rep_votes [rai::test_genesis_key.pub]);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
auto winner (node1.ledger.winner (transaction, votes1->votes));
|
||||
ASSERT_EQ (send2, *winner.second);
|
||||
ASSERT_EQ (*send2, *winner.second);
|
||||
}
|
||||
|
||||
// Lower sequence numbers are ignored
|
||||
|
@ -828,32 +828,32 @@ TEST (votes, add_old)
|
|||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, send1).code);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, *send1).code);
|
||||
}
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, send1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, send1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
auto votes1 (node1.active.roots.find (send1.root ())->election);
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 2, send1.clone ());
|
||||
auto votes1 (node1.active.roots.find (send1->root ())->election);
|
||||
rai::vote vote1 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 2, send1);
|
||||
node1.vote_processor.vote (vote1, rai::endpoint ());
|
||||
rai::keypair key2;
|
||||
rai::send_block send2 (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
rai::vote vote2 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send2.clone ());
|
||||
auto send2 (std::make_shared <rai::send_block> (genesis.hash (), key2.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
rai::vote vote2 (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 1, send2);
|
||||
node1.vote_processor.vote (vote2, rai::endpoint ());
|
||||
ASSERT_EQ (2, votes1->votes.rep_votes.size ());
|
||||
ASSERT_NE (votes1->votes.rep_votes.end (), votes1->votes.rep_votes.find (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (send1, *votes1->votes.rep_votes [rai::test_genesis_key.pub]);
|
||||
ASSERT_EQ (*send1, *votes1->votes.rep_votes [rai::test_genesis_key.pub]);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
auto winner (node1.ledger.winner (transaction, votes1->votes));
|
||||
ASSERT_EQ (send1, *winner.second);
|
||||
ASSERT_EQ (*send1, *winner.second);
|
||||
}
|
||||
|
||||
// Query for block successor
|
||||
|
|
|
@ -148,8 +148,8 @@ TEST (network, multi_keepalive)
|
|||
TEST (network, send_discarded_publish)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
std::unique_ptr <rai::send_block> block (new rai::send_block (1, 1, 2, rai::keypair ().prv, 4, system.work.generate (1)));
|
||||
system.nodes [0]->network.republish_block (*block);
|
||||
auto block (std::make_shared <rai::send_block> (1, 1, 2, rai::keypair ().prv, 4, system.work.generate (1)));
|
||||
system.nodes [0]->network.republish_block (block);
|
||||
rai::genesis genesis;
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [1]->latest (rai::test_genesis_key.pub));
|
||||
|
@ -167,8 +167,8 @@ TEST (network, send_discarded_publish)
|
|||
TEST (network, send_invalid_publish)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
std::unique_ptr <rai::send_block> block (new rai::send_block (1, 1, 20, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (1)));
|
||||
system.nodes [0]->network.republish_block (*block);
|
||||
auto block (std::make_shared <rai::send_block> (1, 1, 20, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (1)));
|
||||
system.nodes [0]->network.republish_block (block);
|
||||
rai::genesis genesis;
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [1]->latest (rai::test_genesis_key.pub));
|
||||
|
@ -257,18 +257,18 @@ TEST (receivable_processor, confirm_insufficient_pos)
|
|||
rai::system system (24000, 1);
|
||||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block block1 (genesis.hash (), 0, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (block1).code);
|
||||
auto block1 (std::make_shared <rai::send_block> (genesis.hash (), 0, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (*block1).code);
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, block1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, block1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
rai::keypair key1;
|
||||
rai::vote vote (key1.pub, key1.prv, 0, block1.clone ());
|
||||
rai::vote vote (key1.pub, key1.prv, 0, block1);
|
||||
rai::confirm_ack con1 (vote);
|
||||
node1.process_message (con1, node1.network.endpoint ());
|
||||
}
|
||||
|
@ -278,17 +278,17 @@ TEST (receivable_processor, confirm_sufficient_pos)
|
|||
rai::system system (24000, 1);
|
||||
auto & node1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block block1 (genesis.hash (), 0, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (block1).code);
|
||||
auto block1 (std::make_shared <rai::send_block> (genesis.hash (), 0, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
ASSERT_EQ (rai::process_result::progress, node1.process (*block1).code);
|
||||
auto node_l (system.nodes [0]);
|
||||
{
|
||||
rai::transaction transaction (node1.store.environment, nullptr, true);
|
||||
node1.active.start (transaction, block1, [node_l] (rai::block & block_a)
|
||||
node1.active.start (transaction, block1, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
rai::vote vote (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 0, block1.clone ());
|
||||
rai::vote vote (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 0, block1);
|
||||
rai::confirm_ack con1 (vote);
|
||||
node1.process_message (con1, node1.network.endpoint ());
|
||||
}
|
||||
|
@ -301,13 +301,13 @@ TEST (receivable_processor, send_with_receive)
|
|||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::block_hash latest1 (system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
std::unique_ptr <rai::send_block> block1 (new rai::send_block (latest1, key2.pub, amount - system.nodes [0]->config.receive_minimum.number (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (latest1)));
|
||||
auto block1 (std::make_shared <rai::send_block> (latest1, key2.pub, amount - system.nodes [0]->config.receive_minimum.number (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (latest1)));
|
||||
ASSERT_EQ (amount, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [0]->balance (key2.pub));
|
||||
ASSERT_EQ (amount, system.nodes [1]->balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [1]->balance (key2.pub));
|
||||
system.nodes [0]->process_receive_republish (block1->clone ());
|
||||
system.nodes [1]->process_receive_republish (block1->clone ());
|
||||
system.nodes [0]->process_receive_republish (block1);
|
||||
system.nodes [1]->process_receive_republish (block1);
|
||||
ASSERT_EQ (amount - system.nodes [0]->config.receive_minimum.number (), system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [0]->balance (key2.pub));
|
||||
ASSERT_EQ (amount - system.nodes [0]->config.receive_minimum.number (), system.nodes [1]->balance (rai::test_genesis_key.pub));
|
||||
|
|
|
@ -180,8 +180,8 @@ TEST (node, quick_confirm)
|
|||
rai::keypair key;
|
||||
rai::block_hash previous (system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
system.wallet (0)->insert_adhoc (key.prv);
|
||||
rai::send_block send (previous, key.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (previous));
|
||||
system.nodes [0]->process_receive_republish (send.clone ());
|
||||
auto send (std::make_shared <rai::send_block> (previous, key.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (previous)));
|
||||
system.nodes [0]->process_receive_republish (send);
|
||||
auto iterations (0);
|
||||
while (system.nodes [0]->balance (key.pub).is_zero ())
|
||||
{
|
||||
|
@ -255,9 +255,9 @@ TEST (node, receive_gap)
|
|||
rai::system system (24000, 1);
|
||||
auto & node1 (*system.nodes [0]);
|
||||
ASSERT_EQ (0, node1.gap_cache.blocks.size ());
|
||||
rai::send_block block (0, 1, 2, rai::keypair ().prv, 4, 5);
|
||||
auto block (std::make_shared <rai::send_block> (0, 1, 2, rai::keypair ().prv, 4, 5));
|
||||
rai::confirm_req message;
|
||||
message.block = block.clone ();
|
||||
message.block = block;
|
||||
node1.process_message (message, node1.network.endpoint ());
|
||||
ASSERT_EQ (1, node1.gap_cache.blocks.size ());
|
||||
}
|
||||
|
@ -632,7 +632,7 @@ TEST (node, confirm_locked)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
system.wallet (0)->enter_password ("1");
|
||||
rai::send_block block (0, 0, 0, rai::keypair ().prv, 0, 0);
|
||||
auto block (std::make_shared <rai::send_block> (0, 0, 0, rai::keypair ().prv, 0, 0));
|
||||
system.nodes [0]->network.republish_block (block);
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,7 @@ TEST (node, block_replace)
|
|||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
ASSERT_EQ (block3->hash (), system.nodes [0]->store.block_successor (transaction, block1->hash ()));
|
||||
}
|
||||
system.nodes [1]->network.republish_block (*block1);
|
||||
system.nodes [1]->network.republish_block (block1);
|
||||
auto iterations1 (0);
|
||||
std::unique_ptr <rai::block> block2;
|
||||
while (block2 == nullptr)
|
||||
|
@ -696,22 +696,22 @@ TEST (node, fork_publish)
|
|||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::keypair key1;
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
rai::keypair key2;
|
||||
rai::send_block send2 (genesis.hash (), key2.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
node1.process_receive_republish (send1.clone ());
|
||||
auto send2 (std::make_shared <rai::send_block> (genesis.hash (), key2.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
node1.process_receive_republish (send1);
|
||||
ASSERT_EQ (1, node1.active.roots.size ());
|
||||
auto existing (node1.active.roots.find (send1.root ()));
|
||||
auto existing (node1.active.roots.find (send1->root ()));
|
||||
ASSERT_NE (node1.active.roots.end (), existing);
|
||||
auto election (existing->election);
|
||||
ASSERT_EQ (2, election->votes.rep_votes.size ());
|
||||
node1.process_receive_republish (send2.clone ());
|
||||
node1.process_receive_republish (send2);
|
||||
auto existing1 (election->votes.rep_votes.find (rai::test_genesis_key.pub));
|
||||
ASSERT_NE (election->votes.rep_votes.end (), existing1);
|
||||
ASSERT_EQ (send1, *existing1->second);
|
||||
ASSERT_EQ (*send1, *existing1->second);
|
||||
rai::transaction transaction (node1.store.environment, nullptr, false);
|
||||
auto winner (node1.ledger.winner (transaction, election->votes));
|
||||
ASSERT_EQ (send1, *winner.second);
|
||||
ASSERT_EQ (*send1, *winner.second);
|
||||
ASSERT_EQ (rai::genesis_amount - 100, winner.first);
|
||||
}
|
||||
ASSERT_TRUE (node0.expired ());
|
||||
|
@ -728,14 +728,14 @@ TEST (node, fork_keep)
|
|||
rai::keypair key2;
|
||||
rai::genesis genesis;
|
||||
// send1 and send2 fork to different accounts
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ()));
|
||||
rai::send_block send2 (genesis.hash (), key2.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ()));
|
||||
node1.process_receive_republish (send1.clone ());
|
||||
node2.process_receive_republish (send1.clone ());
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared <rai::send_block> (genesis.hash (), key2.pub, rai::genesis_amount - 100, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
node1.process_receive_republish (send1);
|
||||
node2.process_receive_republish (send1);
|
||||
ASSERT_EQ (1, node1.active.roots.size ());
|
||||
ASSERT_EQ (1, node2.active.roots.size ());
|
||||
node1.process_receive_republish (send2.clone ());
|
||||
node2.process_receive_republish (send2.clone ());
|
||||
node1.process_receive_republish (send2);
|
||||
node2.process_receive_republish (send2);
|
||||
auto conflict (node2.active.roots.find (genesis.hash ()));
|
||||
ASSERT_NE (node2.active.roots.end (), conflict);
|
||||
auto votes1 (conflict->election);
|
||||
|
@ -744,8 +744,8 @@ TEST (node, fork_keep)
|
|||
{
|
||||
rai::transaction transaction0 (system.nodes [0]->store.environment, nullptr, false);
|
||||
rai::transaction transaction1 (system.nodes [1]->store.environment, nullptr, false);
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction0, send1.hash ()));
|
||||
ASSERT_TRUE (system.nodes [1]->store.block_exists (transaction1, send1.hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction0, send1->hash ()));
|
||||
ASSERT_TRUE (system.nodes [1]->store.block_exists (transaction1, send1->hash ()));
|
||||
}
|
||||
auto iterations (0);
|
||||
// Wait until the genesis rep makes a vote
|
||||
|
@ -759,10 +759,10 @@ TEST (node, fork_keep)
|
|||
rai::transaction transaction1 (system.nodes [1]->store.environment, nullptr, false);
|
||||
// The vote should be in agreement with what we already have.
|
||||
auto winner (node1.ledger.winner (transaction0, votes1->votes));
|
||||
ASSERT_EQ (send1, *winner.second);
|
||||
ASSERT_EQ (*send1, *winner.second);
|
||||
ASSERT_EQ (rai::genesis_amount - 100, winner.first);
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction0, send1.hash ()));
|
||||
ASSERT_TRUE (system.nodes [1]->store.block_exists (transaction1, send1.hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (transaction0, send1->hash ()));
|
||||
ASSERT_TRUE (system.nodes [1]->store.block_exists (transaction1, send1->hash ()));
|
||||
}
|
||||
|
||||
TEST (node, fork_flip)
|
||||
|
@ -885,15 +885,15 @@ TEST (node, fork_bootstrap_flip)
|
|||
system0.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::block_hash latest (system0.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
rai::keypair key1;
|
||||
rai::send_block send1 (latest, key1.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system0.work.generate (latest));
|
||||
auto send1 (std::make_shared <rai::send_block> (latest, key1.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system0.work.generate (latest)));
|
||||
rai::keypair key2;
|
||||
rai::send_block send2 (latest, key2.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system0.work.generate (latest));
|
||||
auto send2 (std::make_shared <rai::send_block> (latest, key2.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system0.work.generate (latest)));
|
||||
// Insert but don't rebroadcast, simulating settled blocks
|
||||
node1.process_receive_many (send1);
|
||||
node2.process_receive_many (send2);
|
||||
{
|
||||
rai::transaction transaction (node2.store.environment, nullptr, false);
|
||||
ASSERT_TRUE (node2.store.block_exists (transaction, send2.hash ()));
|
||||
ASSERT_TRUE (node2.store.block_exists (transaction, send2->hash ()));
|
||||
}
|
||||
node1.network.send_keepalive (node2.network.endpoint ());
|
||||
auto iterations1 (0);
|
||||
|
@ -914,7 +914,7 @@ TEST (node, fork_bootstrap_flip)
|
|||
++iterations2;
|
||||
ASSERT_LT (iterations2, 200);
|
||||
rai::transaction transaction (node2.store.environment, nullptr, false);
|
||||
again = !node2.store.block_exists (transaction, send1.hash ());
|
||||
again = !node2.store.block_exists (transaction, send1->hash ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -951,33 +951,33 @@ TEST (node, fork_open_flip)
|
|||
rai::genesis genesis;
|
||||
rai::keypair rep1;
|
||||
rai::keypair rep2;
|
||||
rai::send_block send1 (genesis.hash (), key1.pub, rai::genesis_amount - 1, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ()));
|
||||
node1.process_receive_republish (send1.clone ());
|
||||
node2.process_receive_republish (send1.clone ());
|
||||
auto send1 (std::make_shared <rai::send_block> (genesis.hash (), key1.pub, rai::genesis_amount - 1, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
node1.process_receive_republish (send1);
|
||||
node2.process_receive_republish (send1);
|
||||
// We should be keeping this block
|
||||
rai::open_block open1 (send1.hash (), rep1.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
auto open1 (std::make_shared <rai::open_block> (send1->hash (), rep1.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
// This block should be evicted
|
||||
rai::open_block open2 (send1.hash (), rep2.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
ASSERT_FALSE (open1 == open2);
|
||||
auto open2 (std::make_shared <rai::open_block> (send1->hash (), rep2.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
ASSERT_FALSE (*open1 == *open2);
|
||||
// node1 gets copy that will remain
|
||||
node1.process_receive_republish (open1.clone ());
|
||||
node1.process_receive_republish (open1);
|
||||
// node2 gets copy that will be evicted
|
||||
node2.process_receive_republish (open2.clone ());
|
||||
node2.process_receive_republish (open2);
|
||||
ASSERT_EQ (2, node1.active.roots.size ());
|
||||
ASSERT_EQ (2, node2.active.roots.size ());
|
||||
// Notify both nodes that a fork exists
|
||||
node1.process_receive_republish (open2.clone ());
|
||||
node2.process_receive_republish (open1.clone ());
|
||||
auto conflict (node2.active.roots.find (open1.root ()));
|
||||
node1.process_receive_republish (open2);
|
||||
node2.process_receive_republish (open1);
|
||||
auto conflict (node2.active.roots.find (open1->root ()));
|
||||
ASSERT_NE (node2.active.roots.end (), conflict);
|
||||
auto votes1 (conflict->election);
|
||||
ASSERT_NE (nullptr, votes1);
|
||||
ASSERT_EQ (1, votes1->votes.rep_votes.size ());
|
||||
ASSERT_TRUE (node1.block (open1.hash ()) != nullptr);
|
||||
ASSERT_TRUE (node2.block (open2.hash ()) != nullptr);
|
||||
ASSERT_TRUE (node1.block (open1->hash ()) != nullptr);
|
||||
ASSERT_TRUE (node2.block (open2->hash ()) != nullptr);
|
||||
auto iterations (0);
|
||||
// Node2 should eventually settle on open1
|
||||
while (node2.block (open1.hash ()) == nullptr)
|
||||
while (node2.block (open1->hash ()) == nullptr)
|
||||
{
|
||||
system.poll ();
|
||||
++iterations;
|
||||
|
@ -985,11 +985,11 @@ TEST (node, fork_open_flip)
|
|||
}
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
auto winner (node2.ledger.winner (transaction, votes1->votes));
|
||||
ASSERT_EQ (open1, *winner.second);
|
||||
ASSERT_EQ (*open1, *winner.second);
|
||||
ASSERT_EQ (rai::genesis_amount - 1, winner.first);
|
||||
ASSERT_TRUE (node1.store.block_exists (transaction, open1.hash ()));
|
||||
ASSERT_TRUE (node2.store.block_exists (transaction, open1.hash ()));
|
||||
ASSERT_FALSE (node2.store.block_exists (transaction, open2.hash ()));
|
||||
ASSERT_TRUE (node1.store.block_exists (transaction, open1->hash ()));
|
||||
ASSERT_TRUE (node2.store.block_exists (transaction, open1->hash ()));
|
||||
ASSERT_FALSE (node2.store.block_exists (transaction, open2->hash ()));
|
||||
}
|
||||
|
||||
TEST (node, coherent_observer)
|
||||
|
@ -1034,10 +1034,10 @@ TEST (node, fork_no_vote_quorum)
|
|||
ASSERT_EQ (rai::process_result::progress, node2.process (send1).code);
|
||||
ASSERT_EQ (rai::process_result::progress, node3.process (send1).code);
|
||||
auto key2 (system.wallet (2)->deterministic_insert ());
|
||||
rai::send_block send2 (block->hash (), key2, (rai::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (block->hash ()));
|
||||
auto send2 (std::make_shared <rai::send_block> (block->hash (), key2, (rai::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (block->hash ())));
|
||||
rai::raw_key key3;
|
||||
ASSERT_FALSE (system.wallet (1)->store.fetch (rai::transaction (system.wallet (1)->store.environment, nullptr, false), key1, key3));
|
||||
rai::vote vote (key1, key3, 0, send2.clone ());
|
||||
rai::vote vote (key1, key3, 0, send2);
|
||||
rai::confirm_ack confirm (vote);
|
||||
std::shared_ptr <std::vector <uint8_t>> bytes (new std::vector <uint8_t>);
|
||||
{
|
||||
|
@ -1102,22 +1102,22 @@ TEST (node, broadcast_elected)
|
|||
system.wallet (0)->insert_adhoc (rep_big.prv);
|
||||
system.wallet (1)->insert_adhoc (rep_small.prv);
|
||||
system.wallet (2)->insert_adhoc (rep_other.prv);
|
||||
rai::send_block fork0 (node2->latest (rai::test_genesis_key.pub), rep_small.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
node0->generate_work (fork0);
|
||||
node0->process_receive_republish (fork0.clone ());
|
||||
node1->process_receive_republish (fork0.clone ());
|
||||
rai::send_block fork1 (node2->latest (rai::test_genesis_key.pub), rep_big.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
node0->generate_work (fork1);
|
||||
auto fork0 (std::make_shared <rai::send_block> (node2->latest (rai::test_genesis_key.pub), rep_small.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
node0->generate_work (*fork0);
|
||||
node0->process_receive_republish (fork0);
|
||||
node1->process_receive_republish (fork0);
|
||||
auto fork1 (std::make_shared <rai::send_block> (node2->latest (rai::test_genesis_key.pub), rep_big.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
node0->generate_work (*fork1);
|
||||
system.wallet (2)->insert_adhoc (rep_small.prv);
|
||||
node2->process_receive_republish (fork1.clone ());
|
||||
node2->process_receive_republish (fork1);
|
||||
//std::cerr << "fork0: " << fork_hash.to_string () << std::endl;
|
||||
//std::cerr << "fork1: " << fork1.hash ().to_string () << std::endl;
|
||||
auto iterations (0);
|
||||
while (!node2->ledger.block_exists (fork0.hash ()))
|
||||
while (!node2->ledger.block_exists (fork0->hash ()))
|
||||
{
|
||||
system.poll ();
|
||||
ASSERT_TRUE (node0->ledger.block_exists (fork0.hash ()));
|
||||
ASSERT_TRUE (node1->ledger.block_exists (fork0.hash ()));
|
||||
ASSERT_TRUE (node0->ledger.block_exists (fork0->hash ()));
|
||||
ASSERT_TRUE (node1->ledger.block_exists (fork0->hash ()));
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 1000);
|
||||
}
|
||||
|
@ -1139,15 +1139,15 @@ TEST (node, rep_self_vote)
|
|||
}
|
||||
system.wallet (0)->insert_adhoc (rep_big.prv);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::send_block block0 (node0->latest (rai::test_genesis_key.pub), rep_big.pub, rai::uint128_t ("0x60000000000000000000000000000000"), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
|
||||
node0->generate_work (block0);
|
||||
ASSERT_EQ (rai::process_result::progress, node0->process (block0).code);
|
||||
auto block0 (std::make_shared <rai::send_block> (node0->latest (rai::test_genesis_key.pub), rep_big.pub, rai::uint128_t ("0x60000000000000000000000000000000"), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
|
||||
node0->generate_work (*block0);
|
||||
ASSERT_EQ (rai::process_result::progress, node0->process (*block0).code);
|
||||
auto & active (node0->active);
|
||||
{
|
||||
rai::transaction transaction (node0->store.environment, nullptr, true);
|
||||
active.start (transaction, block0, [] (rai::block &) {});
|
||||
active.start (transaction, block0, [] (std::shared_ptr <rai::block>) {});
|
||||
}
|
||||
auto existing (active.roots.find (block0.root ()));
|
||||
auto existing (active.roots.find (block0->root ()));
|
||||
ASSERT_NE (active.roots.end (), existing);
|
||||
auto & rep_votes (existing->election->votes.rep_votes);
|
||||
ASSERT_EQ (3, rep_votes.size ());
|
||||
|
|
|
@ -179,7 +179,7 @@ TEST (wallet, send_async)
|
|||
}
|
||||
});
|
||||
bool success (false);
|
||||
system.wallet (0)->send_async (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max (), [&success] (std::unique_ptr <rai::block> block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
system.wallet (0)->send_async (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max (), [&success] (std::shared_ptr <rai::block> block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
thread.join ();
|
||||
ASSERT_TRUE (success);
|
||||
}
|
||||
|
@ -853,4 +853,4 @@ TEST (wallet, version_2_3_upgrade)
|
|||
ASSERT_TRUE (wallet->store.exists (transaction, rai::wallet_store::deterministic_index_special));
|
||||
ASSERT_TRUE (wallet->store.exists (transaction, rai::wallet_store::seed_special));
|
||||
ASSERT_FALSE (wallet->deterministic_insert ().is_zero ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -576,7 +576,7 @@ void rai::bulk_pull_client::received_block (boost::system::error_code const & ec
|
|||
{
|
||||
expected = block->previous ();
|
||||
}
|
||||
connection.node->process_receive_many (*block, [this] (MDB_txn * transaction_a, rai::process_return result_a, rai::block const & block_a)
|
||||
connection.node->process_receive_many (std::move (block), [this] (MDB_txn * transaction_a, rai::process_return result_a, std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
switch (result_a.code)
|
||||
{
|
||||
|
@ -586,14 +586,14 @@ void rai::bulk_pull_client::received_block (boost::system::error_code const & ec
|
|||
case rai::process_result::fork:
|
||||
{
|
||||
auto node_l (connection.node);
|
||||
auto block (node_l->ledger.forked_block (transaction_a, block_a));
|
||||
node_l->active.start (transaction_a, *block, [node_l] (rai::block & block_a)
|
||||
std::shared_ptr <rai::block> block (node_l->ledger.forked_block (transaction_a, *block_a));
|
||||
node_l->active.start (transaction_a, block, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
connection.node->network.broadcast_confirm_req (block_a);
|
||||
connection.node->network.broadcast_confirm_req (*block);
|
||||
BOOST_LOG (connection.node->log) << boost::str (boost::format ("Fork received in bootstrap between: %1% and %2% root %3%") % block_a.hash ().to_string () % block->hash ().to_string () % block_a.root ().to_string ());
|
||||
connection.node->network.broadcast_confirm_req (block);
|
||||
BOOST_LOG (connection.node->log) << boost::str (boost::format ("Fork received in bootstrap between: %1% and %2% root %3%") % block_a->hash ().to_string () % block->hash ().to_string () % block_a->root ().to_string ());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -282,9 +282,9 @@ message (rai::message_type::publish)
|
|||
{
|
||||
}
|
||||
|
||||
rai::publish::publish (std::unique_ptr <rai::block> block_a) :
|
||||
rai::publish::publish (std::shared_ptr <rai::block> block_a) :
|
||||
message (rai::message_type::publish),
|
||||
block (std::move (block_a))
|
||||
block (block_a)
|
||||
{
|
||||
block_type_set (block->type ());
|
||||
}
|
||||
|
@ -324,9 +324,9 @@ message (rai::message_type::confirm_req)
|
|||
{
|
||||
}
|
||||
|
||||
rai::confirm_req::confirm_req (std::unique_ptr <rai::block> block_a) :
|
||||
rai::confirm_req::confirm_req (std::shared_ptr <rai::block> block_a) :
|
||||
message (rai::message_type::confirm_req),
|
||||
block (std::move (block_a))
|
||||
block (block_a)
|
||||
{
|
||||
block_type_set (block->type ());
|
||||
}
|
||||
|
|
|
@ -149,23 +149,23 @@ class publish : public message
|
|||
{
|
||||
public:
|
||||
publish ();
|
||||
publish (std::unique_ptr <rai::block>);
|
||||
publish (std::shared_ptr <rai::block>);
|
||||
void visit (rai::message_visitor &) const override;
|
||||
bool deserialize (rai::stream &) override;
|
||||
void serialize (rai::stream &) override;
|
||||
bool operator == (rai::publish const &) const;
|
||||
std::unique_ptr <rai::block> block;
|
||||
std::shared_ptr <rai::block> block;
|
||||
};
|
||||
class confirm_req : public message
|
||||
{
|
||||
public:
|
||||
confirm_req ();
|
||||
confirm_req (std::unique_ptr <rai::block>);
|
||||
confirm_req (std::shared_ptr <rai::block>);
|
||||
bool deserialize (rai::stream &) override;
|
||||
void serialize (rai::stream &) override;
|
||||
void visit (rai::message_visitor &) const override;
|
||||
bool operator == (rai::confirm_req const &) const;
|
||||
std::unique_ptr <rai::block> block;
|
||||
std::shared_ptr <rai::block> block;
|
||||
};
|
||||
class confirm_ack : public message
|
||||
{
|
||||
|
|
|
@ -149,10 +149,10 @@ void rai::network::republish (rai::block_hash const & hash_a, std::shared_ptr <s
|
|||
});
|
||||
}
|
||||
|
||||
void rai::network::rebroadcast_reps (rai::block & block_a)
|
||||
void rai::network::rebroadcast_reps (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
auto hash (block_a.hash ());
|
||||
rai::publish message (block_a.clone ());
|
||||
auto hash (block_a->hash ());
|
||||
rai::publish message (block_a);
|
||||
std::shared_ptr <std::vector <uint8_t>> bytes (new std::vector <uint8_t>);
|
||||
{
|
||||
rai::vectorstream stream (*bytes);
|
||||
|
@ -166,7 +166,7 @@ void rai::network::rebroadcast_reps (rai::block & block_a)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool confirm_block (rai::node & node_a, T & list_a, std::unique_ptr <rai::block> block_a)
|
||||
bool confirm_block (rai::node & node_a, T & list_a, std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
bool result (false);
|
||||
if (node_a.config.enable_voting)
|
||||
|
@ -176,7 +176,7 @@ bool confirm_block (rai::node & node_a, T & list_a, std::unique_ptr <rai::block>
|
|||
{
|
||||
result = true;
|
||||
auto sequence (node_a.store.sequence_atomic_inc (transaction, pub_a));
|
||||
rai::vote vote (pub_a, prv_a, sequence, block_a->clone ());
|
||||
rai::vote vote (pub_a, prv_a, sequence, block_a);
|
||||
rai::confirm_ack confirm (vote);
|
||||
std::shared_ptr <std::vector <uint8_t>> bytes (new std::vector <uint8_t>);
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ bool confirm_block (rai::node & node_a, T & list_a, std::unique_ptr <rai::block>
|
|||
}
|
||||
|
||||
template <>
|
||||
bool confirm_block (rai::node & node_a, rai::endpoint & peer_a, std::unique_ptr <rai::block> block_a)
|
||||
bool confirm_block (rai::node & node_a, rai::endpoint & peer_a, std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
std::array <rai::endpoint, 1> endpoints;
|
||||
endpoints [0] = peer_a;
|
||||
|
@ -201,22 +201,22 @@ bool confirm_block (rai::node & node_a, rai::endpoint & peer_a, std::unique_ptr
|
|||
return result;
|
||||
}
|
||||
|
||||
void rai::network::republish_block (rai::block & block)
|
||||
void rai::network::republish_block (std::shared_ptr <rai::block> block)
|
||||
{
|
||||
rebroadcast_reps (block);
|
||||
auto hash (block.hash ());
|
||||
auto hash (block->hash ());
|
||||
auto list (node.peers.list ());
|
||||
// If we're a representative, broadcast a signed confirm, otherwise an unsigned publish
|
||||
if (!confirm_block (node, list, block.clone ()))
|
||||
if (!confirm_block (node, list, block))
|
||||
{
|
||||
rai::publish message (block.clone ());
|
||||
rai::publish message (block);
|
||||
std::shared_ptr <std::vector <uint8_t>> bytes (new std::vector <uint8_t>);
|
||||
{
|
||||
rai::vectorstream stream (*bytes);
|
||||
message.serialize (stream);
|
||||
}
|
||||
auto sqrt_list (node.peers.list_sqrt ());
|
||||
auto hash (block.hash ());
|
||||
auto hash (block->hash ());
|
||||
for (auto i (sqrt_list.begin ()), n (sqrt_list.end ()); i != n; ++i)
|
||||
{
|
||||
republish (hash, bytes, *i);
|
||||
|
@ -260,7 +260,7 @@ void rai::network::republish_vote (std::chrono::system_clock::time_point const &
|
|||
}
|
||||
}
|
||||
|
||||
void rai::network::broadcast_confirm_req (rai::block const & block_a)
|
||||
void rai::network::broadcast_confirm_req (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
auto list (node.peers.representatives (std::numeric_limits <size_t>::max ()));
|
||||
for (auto i (list.begin ()), j (list.end ()); i != j; ++i)
|
||||
|
@ -273,9 +273,9 @@ void rai::network::broadcast_confirm_req (rai::block const & block_a)
|
|||
}
|
||||
}
|
||||
|
||||
void rai::network::send_confirm_req (rai::endpoint const & endpoint_a, rai::block const & block)
|
||||
void rai::network::send_confirm_req (rai::endpoint const & endpoint_a, std::shared_ptr <rai::block> block)
|
||||
{
|
||||
rai::confirm_req message (block.clone ());
|
||||
rai::confirm_req message (block);
|
||||
std::shared_ptr <std::vector <uint8_t>> bytes (new std::vector <uint8_t>);
|
||||
{
|
||||
rai::vectorstream stream (*bytes);
|
||||
|
@ -312,7 +312,7 @@ void rep_query (rai::node & node_a, T const & peers_a)
|
|||
for (auto i (peers_a.begin ()), n (peers_a.end ()); i != n; ++i)
|
||||
{
|
||||
node_a.peers.rep_request (*i);
|
||||
node_a.network.send_confirm_req (*i, *block);
|
||||
node_a.network.send_confirm_req (*i, std::move (block));
|
||||
}
|
||||
std::weak_ptr <rai::node> node_w (node_a.shared ());
|
||||
node_a.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [node_w, hash] ()
|
||||
|
@ -361,7 +361,7 @@ public:
|
|||
++node.network.incoming.publish;
|
||||
node.peers.contacted (sender);
|
||||
node.peers.insert (sender);
|
||||
node.process_receive_republish (message_a.block->clone ());
|
||||
node.process_receive_republish (message_a.block);
|
||||
}
|
||||
void confirm_req (rai::confirm_req const & message_a) override
|
||||
{
|
||||
|
@ -372,10 +372,10 @@ public:
|
|||
++node.network.incoming.confirm_req;
|
||||
node.peers.contacted (sender);
|
||||
node.peers.insert (sender);
|
||||
node.process_receive_republish (message_a.block->clone ());
|
||||
node.process_receive_republish (message_a.block);
|
||||
if (node.ledger.block_exists (message_a.block->hash ()))
|
||||
{
|
||||
confirm_block (node, sender, message_a.block->clone ());
|
||||
confirm_block (node, sender, message_a.block);
|
||||
}
|
||||
}
|
||||
void confirm_ack (rai::confirm_ack const & message_a) override
|
||||
|
@ -387,7 +387,7 @@ public:
|
|||
++node.network.incoming.confirm_ack;
|
||||
node.peers.contacted (sender);
|
||||
node.peers.insert (sender);
|
||||
node.process_receive_republish (message_a.vote.block->clone ());
|
||||
node.process_receive_republish (message_a.vote.block);
|
||||
node.vote_processor.vote (message_a.vote, sender);
|
||||
}
|
||||
void bulk_pull (rai::bulk_pull const &) override
|
||||
|
@ -1253,14 +1253,14 @@ node (node_a)
|
|||
{
|
||||
}
|
||||
|
||||
void rai::gap_cache::add (MDB_txn * transaction_a, rai::block const & block_a)
|
||||
void rai::gap_cache::add (MDB_txn * transaction_a, std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
auto hash (block_a.hash ());
|
||||
auto hash (block_a->hash ());
|
||||
std::lock_guard <std::mutex> lock (mutex);
|
||||
auto existing (blocks.get <1>().find (hash));
|
||||
if (existing != blocks.get <1> ().end ())
|
||||
{
|
||||
blocks.get <1> ().modify (existing, [&block_a] (rai::gap_information & info)
|
||||
blocks.get <1> ().modify (existing, [] (rai::gap_information & info)
|
||||
{
|
||||
info.arrival = std::chrono::system_clock::now ();
|
||||
});
|
||||
|
@ -1353,23 +1353,23 @@ void rai::network::confirm_send (rai::confirm_ack const & confirm_a, std::shared
|
|||
});
|
||||
}
|
||||
|
||||
void rai::node::process_receive_republish (std::unique_ptr <rai::block> incoming)
|
||||
void rai::node::process_receive_republish (std::shared_ptr <rai::block> incoming)
|
||||
{
|
||||
std::vector <std::tuple <rai::process_return, std::unique_ptr <rai::block>>> completed;
|
||||
std::vector <std::tuple <rai::process_return, std::shared_ptr <rai::block>>> completed;
|
||||
{
|
||||
assert (incoming != nullptr);
|
||||
process_receive_many (*incoming, [this, &completed] (MDB_txn * transaction_a, rai::process_return result_a, rai::block const & block_a)
|
||||
process_receive_many (incoming, [this, &completed] (MDB_txn * transaction_a, rai::process_return result_a, std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
switch (result_a.code)
|
||||
{
|
||||
case rai::process_result::progress:
|
||||
{
|
||||
auto node_l (shared_from_this ());
|
||||
active.start (transaction_a, block_a, [node_l] (rai::block & block_a)
|
||||
active.start (transaction_a, block_a, [node_l] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
completed.push_back (std::make_tuple (result_a, block_a.clone ()));
|
||||
completed.push_back (std::make_tuple (result_a, block_a));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1385,21 +1385,21 @@ void rai::node::process_receive_republish (std::unique_ptr <rai::block> incoming
|
|||
}
|
||||
}
|
||||
|
||||
void rai::node::process_receive_many (rai::block const & block_a, std::function <void (MDB_txn *, rai::process_return, rai::block const &)> completed_a)
|
||||
void rai::node::process_receive_many (std::shared_ptr <rai::block> block_a, std::function <void (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>)> completed_a)
|
||||
{
|
||||
std::vector <std::unique_ptr <rai::block>> blocks;
|
||||
blocks.push_back (block_a.clone ());
|
||||
std::vector <std::shared_ptr <rai::block>> blocks;
|
||||
blocks.push_back (block_a);
|
||||
while (!blocks.empty ())
|
||||
{
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
auto count (0);
|
||||
while (!blocks.empty () && count < rai::blocks_per_transaction)
|
||||
{
|
||||
auto block (std::move (blocks.back ()));
|
||||
auto block (blocks.back ());
|
||||
blocks.pop_back ();
|
||||
auto hash (block->hash ());
|
||||
auto process_result (process_receive_one (transaction, *block));
|
||||
completed_a (transaction, process_result, *block);
|
||||
auto process_result (process_receive_one (transaction, block));
|
||||
completed_a (transaction, process_result, block);
|
||||
switch (process_result.code)
|
||||
{
|
||||
case rai::process_result::progress:
|
||||
|
@ -1425,10 +1425,10 @@ void rai::node::process_receive_many (rai::block const & block_a, std::function
|
|||
}
|
||||
}
|
||||
|
||||
rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai::block const & block_a)
|
||||
rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
rai::process_return result;
|
||||
result = ledger.process (transaction_a, block_a);
|
||||
result = ledger.process (transaction_a, *block_a);
|
||||
switch (result.code)
|
||||
{
|
||||
case rai::process_result::progress:
|
||||
|
@ -1436,8 +1436,8 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
std::string block;
|
||||
block_a.serialize_json (block);
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Processing block %1% %2%") % block_a.hash ().to_string () % block);
|
||||
block_a->serialize_json (block);
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Processing block %1% %2%") % block_a->hash ().to_string () % block);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1445,9 +1445,9 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Gap previous for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Gap previous for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
store.unchecked_put (transaction_a, block_a.previous (), block_a);
|
||||
store.unchecked_put (transaction_a, block_a->previous (), *block_a);
|
||||
gap_cache.add (transaction_a, block_a);
|
||||
break;
|
||||
}
|
||||
|
@ -1455,24 +1455,24 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Gap source for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Gap source for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
store.unchecked_put (transaction_a, block_a.source (), block_a);
|
||||
store.unchecked_put (transaction_a, block_a->source (), *block_a);
|
||||
gap_cache.add (transaction_a, block_a);
|
||||
break;
|
||||
}
|
||||
case rai::process_result::old:
|
||||
{
|
||||
{
|
||||
auto root (block_a.root ());
|
||||
auto hash (block_a.hash ());
|
||||
auto root (block_a->root ());
|
||||
auto hash (block_a->hash ());
|
||||
auto existing (store.block_get (transaction_a, hash));
|
||||
if (existing != nullptr)
|
||||
{
|
||||
// Replace block with one that has higher work value
|
||||
if (work.work_value (root, block_a.block_work ()) > work.work_value (root, existing->block_work ()))
|
||||
if (work.work_value (root, block_a->block_work ()) > work.work_value (root, existing->block_work ()))
|
||||
{
|
||||
store.block_put (transaction_a, hash, block_a, store.block_successor (transaction_a, hash));
|
||||
store.block_put (transaction_a, hash, *block_a, store.block_successor (transaction_a, hash));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1482,7 +1482,7 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
}
|
||||
if (config.logging.ledger_duplicate_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Old for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Old for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1490,7 +1490,7 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Bad signature for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Bad signature for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1498,7 +1498,7 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Overspend for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Overspend for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1506,7 +1506,7 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Unreceivable for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Unreceivable for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1514,7 +1514,7 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Not receive from send for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Not receive from send for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1522,7 +1522,7 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Fork for: %1% root: %2%") % block_a.hash ().to_string () % block_a.root ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Fork for: %1% root: %2%") % block_a->hash ().to_string () % block_a->root ().to_string ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1530,7 +1530,7 @@ rai::process_return rai::node::process_receive_one (MDB_txn * transaction_a, rai
|
|||
{
|
||||
if (config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Account mismatch for: %1%") % block_a.hash ().to_string ());
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Account mismatch for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2077,8 +2077,9 @@ namespace
|
|||
class confirmed_visitor : public rai::block_visitor
|
||||
{
|
||||
public:
|
||||
confirmed_visitor (rai::node & node_a) :
|
||||
node (node_a)
|
||||
confirmed_visitor (rai::node & node_a, std::shared_ptr <rai::block> block_a) :
|
||||
node (node_a),
|
||||
block (block_a)
|
||||
{
|
||||
}
|
||||
void send_block (rai::send_block const & block_a) override
|
||||
|
@ -2095,10 +2096,10 @@ public:
|
|||
auto error (node.store.pending_get (transaction, rai::pending_key (block_a.hashables.destination, block_a.hash ()), pending));
|
||||
if (!error)
|
||||
{
|
||||
auto block_l (std::shared_ptr <rai::send_block> (static_cast <rai::send_block *> (block_a.clone ().release ())));
|
||||
auto node_l (node.shared ());
|
||||
auto amount (pending.amount.number ());
|
||||
wallet->receive_async (*block_l, representative, amount, [] (std::unique_ptr <rai::block> block_a) {});
|
||||
assert (block.get () == &block_a);
|
||||
wallet->receive_async (block, representative, amount, [] (std::shared_ptr <rai::block>) {});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2120,13 +2121,14 @@ public:
|
|||
{
|
||||
}
|
||||
rai::node & node;
|
||||
std::shared_ptr <rai::block> block;
|
||||
};
|
||||
}
|
||||
|
||||
void rai::node::process_confirmed (rai::block const & confirmed_a)
|
||||
void rai::node::process_confirmed (std::shared_ptr <rai::block> confirmed_a)
|
||||
{
|
||||
confirmed_visitor visitor (*this);
|
||||
confirmed_a.visit (visitor);
|
||||
confirmed_visitor visitor (*this, confirmed_a);
|
||||
confirmed_a->visit (visitor);
|
||||
}
|
||||
|
||||
void rai::node::process_message (rai::message & message_a, rai::endpoint const & sender_a)
|
||||
|
@ -2489,14 +2491,14 @@ std::shared_ptr <rai::node> rai::node::shared ()
|
|||
return shared_from_this ();
|
||||
}
|
||||
|
||||
rai::election::election (MDB_txn * transaction_a, rai::node & node_a, rai::block const & block_a, std::function <void (rai::block &)> const & confirmation_action_a) :
|
||||
rai::election::election (MDB_txn * transaction_a, rai::node & node_a, std::shared_ptr <rai::block> block_a, std::function <void (std::shared_ptr <rai::block>)> const & confirmation_action_a) :
|
||||
confirmation_action (confirmation_action_a),
|
||||
votes (block_a),
|
||||
node (node_a),
|
||||
last_vote (std::chrono::system_clock::now ()),
|
||||
last_winner (block_a.clone ())
|
||||
last_winner (block_a)
|
||||
{
|
||||
assert (node_a.store.block_exists (transaction_a, block_a.hash ()));
|
||||
assert (node_a.store.block_exists (transaction_a, block_a->hash ()));
|
||||
confirmed.clear ();
|
||||
compute_rep_votes (transaction_a);
|
||||
}
|
||||
|
@ -2505,7 +2507,7 @@ void rai::election::compute_rep_votes (MDB_txn * transaction_a)
|
|||
{
|
||||
node.wallets.foreach_representative (transaction_a, [this, transaction_a] (rai::public_key const & pub_a, rai::raw_key const & prv_a)
|
||||
{
|
||||
rai::vote vote (pub_a, prv_a, this->node.store.sequence_atomic_inc (transaction_a, pub_a), last_winner->clone ());
|
||||
rai::vote vote (pub_a, prv_a, this->node.store.sequence_atomic_inc (transaction_a, pub_a), last_winner);
|
||||
this->votes.vote (vote);
|
||||
});
|
||||
}
|
||||
|
@ -2516,7 +2518,7 @@ void rai::election::broadcast_winner ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, true);
|
||||
compute_rep_votes (transaction);
|
||||
}
|
||||
node.network.republish_block (*last_winner);
|
||||
node.network.republish_block (last_winner);
|
||||
}
|
||||
|
||||
rai::uint128_t rai::election::quorum_threshold (MDB_txn * transaction_a, rai::ledger & ledger_a)
|
||||
|
@ -2565,7 +2567,7 @@ void rai::election::confirm_once (MDB_txn * transaction_a)
|
|||
auto confirmation_action_l (confirmation_action);
|
||||
node.background ([winner_l, confirmation_action_l] ()
|
||||
{
|
||||
confirmation_action_l (*winner_l);
|
||||
confirmation_action_l (winner_l);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2665,10 +2667,10 @@ void rai::active_transactions::stop ()
|
|||
roots.clear ();
|
||||
}
|
||||
|
||||
void rai::active_transactions::start (MDB_txn * transaction_a, rai::block const & block_a, std::function <void (rai::block &)> const & confirmation_action_a)
|
||||
void rai::active_transactions::start (MDB_txn * transaction_a, std::shared_ptr <rai::block> block_a, std::function <void (std::shared_ptr <rai::block>)> const & confirmation_action_a)
|
||||
{
|
||||
std::lock_guard <std::mutex> lock (mutex);
|
||||
auto root (block_a.root ());
|
||||
auto root (block_a->root ());
|
||||
auto existing (roots.find (root));
|
||||
if (existing == roots.end ())
|
||||
{
|
||||
|
|
|
@ -38,10 +38,10 @@ namespace rai
|
|||
class node;
|
||||
class election : public std::enable_shared_from_this <rai::election>
|
||||
{
|
||||
std::function <void (rai::block &)> confirmation_action;
|
||||
std::function <void (std::shared_ptr <rai::block>)> confirmation_action;
|
||||
void confirm_once (MDB_txn *);
|
||||
public:
|
||||
election (MDB_txn *, rai::node &, rai::block const &, std::function <void (rai::block &)> const &);
|
||||
election (MDB_txn *, rai::node &, std::shared_ptr <rai::block>, std::function <void (std::shared_ptr <rai::block>)> const &);
|
||||
void vote (rai::vote const &);
|
||||
// Check if we have vote quorum
|
||||
bool have_quorum (MDB_txn *);
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
active_transactions (rai::node &);
|
||||
// Start an election for a block
|
||||
// Call action with confirmed block, may be different than what we started with
|
||||
void start (MDB_txn *, rai::block const &, std::function <void (rai::block &)> const &);
|
||||
void start (MDB_txn *, std::shared_ptr <rai::block>, std::function <void (std::shared_ptr <rai::block>)> const &);
|
||||
void vote (rai::vote const &);
|
||||
// Is the root of this block in the roots container
|
||||
bool active (rai::block const &);
|
||||
|
@ -130,7 +130,7 @@ class gap_cache
|
|||
{
|
||||
public:
|
||||
gap_cache (rai::node &);
|
||||
void add (MDB_txn *, rai::block const &);
|
||||
void add (MDB_txn *, std::shared_ptr <rai::block>);
|
||||
void vote (rai::vote const &);
|
||||
rai::uint128_t bootstrap_threshold (MDB_txn *);
|
||||
void purge_old ();
|
||||
|
@ -273,16 +273,16 @@ public:
|
|||
void stop ();
|
||||
void receive_action (boost::system::error_code const &, size_t);
|
||||
void rpc_action (boost::system::error_code const &, size_t);
|
||||
void rebroadcast_reps (rai::block &);
|
||||
void rebroadcast_reps (std::shared_ptr <rai::block>);
|
||||
void republish_vote (std::chrono::system_clock::time_point const &, rai::vote const &);
|
||||
void republish_block (rai::block &);
|
||||
void republish_block (std::shared_ptr <rai::block>);
|
||||
void republish (rai::block_hash const &, std::shared_ptr <std::vector <uint8_t>>, rai::endpoint);
|
||||
void publish_broadcast (std::vector <rai::peer_information> &, std::unique_ptr <rai::block>);
|
||||
void confirm_send (rai::confirm_ack const &, std::shared_ptr <std::vector <uint8_t>>, rai::endpoint const &);
|
||||
void merge_peers (std::array <rai::endpoint, 8> const &);
|
||||
void send_keepalive (rai::endpoint const &);
|
||||
void broadcast_confirm_req (rai::block const &);
|
||||
void send_confirm_req (rai::endpoint const &, rai::block const &);
|
||||
void broadcast_confirm_req (std::shared_ptr <rai::block>);
|
||||
void send_confirm_req (rai::endpoint const &, std::shared_ptr <rai::block>);
|
||||
void send_buffer (uint8_t const *, size_t, rai::endpoint const &, std::function <void (boost::system::error_code const &, size_t)>);
|
||||
rai::endpoint endpoint ();
|
||||
rai::endpoint remote;
|
||||
|
@ -422,11 +422,11 @@ public:
|
|||
void stop ();
|
||||
std::shared_ptr <rai::node> shared ();
|
||||
int store_version ();
|
||||
void process_confirmed (rai::block const &);
|
||||
void process_confirmed (std::shared_ptr <rai::block>);
|
||||
void process_message (rai::message &, rai::endpoint const &);
|
||||
void process_receive_republish (std::unique_ptr <rai::block>);
|
||||
void process_receive_many (rai::block const &, std::function <void (MDB_txn *, rai::process_return, rai::block const &)> = [] (MDB_txn *, rai::process_return, rai::block const &) {});
|
||||
rai::process_return process_receive_one (MDB_txn *, rai::block const &);
|
||||
void process_receive_republish (std::shared_ptr <rai::block>);
|
||||
void process_receive_many (std::shared_ptr <rai::block>, std::function <void (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>)> = [] (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>) {});
|
||||
rai::process_return process_receive_one (MDB_txn *, std::shared_ptr <rai::block>);
|
||||
rai::process_return process (rai::block const &);
|
||||
void keepalive_preconfigured (std::vector <std::string> const &);
|
||||
rai::block_hash latest (rai::account const &);
|
||||
|
|
|
@ -488,7 +488,7 @@ void rai::rpc_handler::account_representative_set ()
|
|||
if (!error)
|
||||
{
|
||||
auto response_a (response);
|
||||
wallet->change_async (account, representative, [response_a] (std::unique_ptr <rai::block> block)
|
||||
wallet->change_async (account, representative, [response_a] (std::shared_ptr <rai::block> block)
|
||||
{
|
||||
rai::block_hash hash (0);
|
||||
if (block != nullptr)
|
||||
|
@ -1638,7 +1638,7 @@ void rai::rpc_handler::receive ()
|
|||
if (node.store.pending_exists (transaction, rai::pending_key (account, hash)))
|
||||
{
|
||||
auto response_a (response);
|
||||
existing->second->receive_async (static_cast <rai::send_block &>(*block), account, rai::genesis_amount, [response_a] (std::unique_ptr <rai::block> block_a)
|
||||
existing->second->receive_async (std::move (block), account, rai::genesis_amount, [response_a] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
rai::uint256_union hash_a (0);
|
||||
if (block_a != nullptr)
|
||||
|
@ -1720,7 +1720,7 @@ void rai::rpc_handler::republish ()
|
|||
while (!hash.is_zero ())
|
||||
{
|
||||
block = node.store.block_get (transaction, hash);
|
||||
node.network.republish_block (*block);
|
||||
node.network.republish_block (std::move (block));
|
||||
hash = node.store.block_successor (transaction, hash);
|
||||
}
|
||||
boost::property_tree::ptree response_l;
|
||||
|
@ -1796,7 +1796,7 @@ void rai::rpc_handler::send ()
|
|||
{
|
||||
auto rpc_l (shared_from_this ());
|
||||
auto response_a (response);
|
||||
existing->second->send_async (source, destination, amount.number (), [response_a] (std::unique_ptr <rai::block> block_a)
|
||||
existing->second->send_async (source, destination, amount.number (), [response_a] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
rai::uint256_union hash (0);
|
||||
if (block_a != nullptr)
|
||||
|
|
|
@ -161,7 +161,7 @@ void rai::system::generate_rollback (rai::node & node_a, std::vector <rai::accou
|
|||
|
||||
void rai::system::generate_receive (rai::node & node_a)
|
||||
{
|
||||
std::unique_ptr <rai::block> send_block;
|
||||
std::shared_ptr <rai::send_block> send_block;
|
||||
{
|
||||
rai::transaction transaction (node_a.store.environment, nullptr, false);
|
||||
rai::uint256_union random_block;
|
||||
|
@ -171,13 +171,14 @@ void rai::system::generate_receive (rai::node & node_a)
|
|||
{
|
||||
rai::pending_key send_hash (i->first);
|
||||
rai::pending_info info (i->second);
|
||||
send_block = node_a.store.block_get (transaction, send_hash.hash);
|
||||
assert (send_block != nullptr);
|
||||
auto block (node_a.store.block_get (transaction, send_hash.hash));
|
||||
assert (dynamic_cast <rai::send_block *> (block.get ()) != nullptr);
|
||||
send_block.reset (static_cast <rai::send_block *> (block.release ()));
|
||||
}
|
||||
}
|
||||
if (send_block != nullptr)
|
||||
{
|
||||
auto receive_error (wallet (0)->receive_sync (static_cast <rai::send_block &> (*send_block), rai::genesis_account, std::numeric_limits<rai::uint128_t>::max ()));
|
||||
auto receive_error (wallet (0)->receive_sync (std::move (send_block), rai::genesis_account, std::numeric_limits<rai::uint128_t>::max ()));
|
||||
(void) receive_error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -949,10 +949,10 @@ bool check_ownership (rai::wallets & wallets_a, rai::account const & account_a)
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::wallet::receive_action (rai::send_block const & send_a, rai::account const & representative_a, rai::uint128_union const & amount_a)
|
||||
std::shared_ptr <rai::block> rai::wallet::receive_action (rai::send_block const & send_a, rai::account const & representative_a, rai::uint128_union const & amount_a)
|
||||
{
|
||||
auto hash (send_a.hash ());
|
||||
std::unique_ptr <rai::block> block;
|
||||
std::shared_ptr <rai::block> block;
|
||||
if (node.config.receive_minimum.number () <= amount_a.number ())
|
||||
{
|
||||
rai::transaction transaction (node.ledger.store.environment, nullptr, false);
|
||||
|
@ -991,7 +991,7 @@ std::unique_ptr <rai::block> rai::wallet::receive_action (rai::send_block const
|
|||
if (block != nullptr)
|
||||
{
|
||||
assert (block != nullptr);
|
||||
node.process_receive_republish (block->clone ());
|
||||
node.process_receive_republish (block);
|
||||
auto hash (block->hash ());
|
||||
auto this_l (shared_from_this ());
|
||||
auto source (send_a.hashables.destination);
|
||||
|
@ -1003,9 +1003,9 @@ std::unique_ptr <rai::block> rai::wallet::receive_action (rai::send_block const
|
|||
return block;
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::wallet::change_action (rai::account const & source_a, rai::account const & representative_a)
|
||||
std::shared_ptr <rai::block> rai::wallet::change_action (rai::account const & source_a, rai::account const & representative_a)
|
||||
{
|
||||
std::unique_ptr <rai::block> block;
|
||||
std::shared_ptr <rai::block> block;
|
||||
{
|
||||
rai::transaction transaction (store.environment, nullptr, false);
|
||||
if (store.valid_password (transaction))
|
||||
|
@ -1029,7 +1029,7 @@ std::unique_ptr <rai::block> rai::wallet::change_action (rai::account const & so
|
|||
if (block != nullptr)
|
||||
{
|
||||
assert (block != nullptr);
|
||||
node.process_receive_republish (block->clone ());
|
||||
node.process_receive_republish (block);
|
||||
auto hash (block->hash ());
|
||||
auto this_l (shared_from_this ());
|
||||
node.wallets.queue_wallet_action (source_a, rai::wallets::generate_priority, [this_l, source_a, hash]
|
||||
|
@ -1040,9 +1040,9 @@ std::unique_ptr <rai::block> rai::wallet::change_action (rai::account const & so
|
|||
return block;
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::wallet::send_action (rai::account const & source_a, rai::account const & account_a, rai::uint128_t const & amount_a)
|
||||
std::shared_ptr <rai::block> rai::wallet::send_action (rai::account const & source_a, rai::account const & account_a, rai::uint128_t const & amount_a)
|
||||
{
|
||||
std::unique_ptr <rai::block> block;
|
||||
std::shared_ptr <rai::block> block;
|
||||
{
|
||||
rai::transaction transaction (store.environment, nullptr, false);
|
||||
if (store.valid_password (transaction))
|
||||
|
@ -1070,7 +1070,7 @@ std::unique_ptr <rai::block> rai::wallet::send_action (rai::account const & sour
|
|||
if (block != nullptr)
|
||||
{
|
||||
assert (block != nullptr);
|
||||
node.process_receive_republish (block->clone ());
|
||||
node.process_receive_republish (block);
|
||||
auto hash (block->hash ());
|
||||
auto this_l (shared_from_this ());
|
||||
node.wallets.queue_wallet_action (source_a, rai::wallets::generate_priority, [this_l, source_a, hash]
|
||||
|
@ -1084,55 +1084,55 @@ std::unique_ptr <rai::block> rai::wallet::send_action (rai::account const & sour
|
|||
bool rai::wallet::change_sync (rai::account const & source_a, rai::account const & representative_a)
|
||||
{
|
||||
std::promise <bool> result;
|
||||
change_async (source_a, representative_a, [this, source_a, representative_a, &result] (std::unique_ptr <rai::block> block_a)
|
||||
change_async (source_a, representative_a, [this, source_a, representative_a, &result] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
result.set_value (block_a == nullptr);
|
||||
});
|
||||
return result.get_future ().get ();
|
||||
}
|
||||
|
||||
void rai::wallet::change_async (rai::account const & source_a, rai::account const & representative_a, std::function <void (std::unique_ptr <rai::block>)> const & action_a)
|
||||
void rai::wallet::change_async (rai::account const & source_a, rai::account const & representative_a, std::function <void (std::shared_ptr <rai::block>)> const & action_a)
|
||||
{
|
||||
node.wallets.queue_wallet_action (source_a, rai::wallets::high_priority, [this, source_a, representative_a, action_a] ()
|
||||
{
|
||||
assert (!check_ownership (node.wallets, source_a));
|
||||
auto block (change_action (source_a, representative_a));
|
||||
action_a (std::move (block));
|
||||
action_a (block);
|
||||
});
|
||||
}
|
||||
|
||||
bool rai::wallet::receive_sync (rai::send_block const & block_a, rai::account const & representative_a, rai::uint128_t const & amount_a)
|
||||
bool rai::wallet::receive_sync (std::shared_ptr <rai::block> block_a, rai::account const & representative_a, rai::uint128_t const & amount_a)
|
||||
{
|
||||
std::promise <bool> result;
|
||||
receive_async (block_a, representative_a, amount_a, [&result] (std::unique_ptr <rai::block> block_a)
|
||||
receive_async (block_a, representative_a, amount_a, [&result] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
result.set_value (block_a == nullptr);
|
||||
});
|
||||
return result.get_future ().get ();
|
||||
}
|
||||
|
||||
void rai::wallet::receive_async (rai::send_block const & block_a, rai::account const & representative_a, rai::uint128_t const & amount_a, std::function <void (std::unique_ptr <rai::block>)> const & action_a)
|
||||
void rai::wallet::receive_async (std::shared_ptr <rai::block> block_a, rai::account const & representative_a, rai::uint128_t const & amount_a, std::function <void (std::shared_ptr <rai::block>)> const & action_a)
|
||||
{
|
||||
std::shared_ptr <rai::send_block> block_l (static_cast <rai::send_block *> (block_a.clone ().release ()));
|
||||
node.wallets.queue_wallet_action (block_a.hashables.destination, amount_a, [this, block_l, representative_a, amount_a, action_a] ()
|
||||
assert (dynamic_cast <rai::send_block *> (block_a.get ()) != nullptr);
|
||||
node.wallets.queue_wallet_action (static_cast <rai::send_block *> (block_a.get ())->hashables.destination, amount_a, [this, block_a, representative_a, amount_a, action_a] ()
|
||||
{
|
||||
assert (!check_ownership (node.wallets, block_l->hashables.destination));
|
||||
auto block (receive_action (*block_l, representative_a, amount_a));
|
||||
action_a (std::move (block));
|
||||
assert (!check_ownership (node.wallets, static_cast <rai::send_block *> (block_a.get ())->hashables.destination));
|
||||
auto block (receive_action (*static_cast <rai::send_block *> (block_a.get ()), representative_a, amount_a));
|
||||
action_a (block);
|
||||
});
|
||||
}
|
||||
|
||||
rai::block_hash rai::wallet::send_sync (rai::account const & source_a, rai::account const & account_a, rai::uint128_t const & amount_a)
|
||||
{
|
||||
std::promise <rai::block_hash> result;
|
||||
send_async (source_a, account_a, amount_a, [&result] (std::unique_ptr <rai::block> block_a)
|
||||
send_async (source_a, account_a, amount_a, [&result] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
result.set_value (block_a->hash ());
|
||||
});
|
||||
return result.get_future ().get ();
|
||||
}
|
||||
|
||||
void rai::wallet::send_async (rai::account const & source_a, rai::account const & account_a, rai::uint128_t const & amount_a, std::function <void (std::unique_ptr <rai::block>)> const & action_a)
|
||||
void rai::wallet::send_async (rai::account const & source_a, rai::account const & account_a, rai::uint128_t const & amount_a, std::function <void (std::shared_ptr <rai::block>)> const & action_a)
|
||||
{
|
||||
node.background ([this, source_a, account_a, amount_a, action_a] ()
|
||||
{
|
||||
|
@ -1140,7 +1140,7 @@ void rai::wallet::send_async (rai::account const & source_a, rai::account const
|
|||
{
|
||||
assert (!check_ownership (node.wallets, source_a));
|
||||
auto block (send_action (source_a, account_a, amount_a));
|
||||
action_a (std::move (block));
|
||||
action_a (block);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1230,16 +1230,16 @@ public:
|
|||
if (already_searched.find (account) == already_searched.end ())
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
std::shared_ptr <rai::block> block_l (wallet->node.store.block_get (transaction, info.head).release ());
|
||||
std::shared_ptr <rai::block> block_l (wallet->node.store.block_get (transaction, info.head));
|
||||
wallet->node.background ([this_l, account, block_l]
|
||||
{
|
||||
rai::transaction transaction (this_l->wallet->node.store.environment, nullptr, true);
|
||||
this_l->wallet->node.active.start (transaction, *block_l, [this_l, account] (rai::block &)
|
||||
this_l->wallet->node.active.start (transaction, block_l, [this_l, account] (std::shared_ptr <rai::block>)
|
||||
{
|
||||
// If there were any forks for this account they've been rolled back and we can receive anything remaining from this account
|
||||
this_l->receive_all (account);
|
||||
});
|
||||
this_l->wallet->node.network.broadcast_confirm_req (*block_l);
|
||||
this_l->wallet->node.network.broadcast_confirm_req (block_l);
|
||||
});
|
||||
already_searched.insert (account);
|
||||
}
|
||||
|
@ -1263,13 +1263,11 @@ public:
|
|||
if (wallet->store.valid_password (transaction))
|
||||
{
|
||||
rai::pending_key key (i->first);
|
||||
auto block_l (wallet->node.store.block_get (transaction, key.hash));
|
||||
assert (dynamic_cast <rai::send_block *> (block_l.get ()) != nullptr);
|
||||
std::shared_ptr <rai::send_block> block (static_cast <rai::send_block *> (block_l.release ()));
|
||||
std::shared_ptr <rai::block> block (wallet->node.store.block_get (transaction, key.hash));
|
||||
auto wallet_l (wallet);
|
||||
auto amount (pending.amount.number ());
|
||||
BOOST_LOG (wallet_l->node.log) << boost::str (boost::format ("Receiving block: %1%") % block->hash ().to_string ());
|
||||
wallet_l->receive_async (*block, representative, amount, [wallet_l, block] (std::unique_ptr <rai::block> block_a)
|
||||
wallet_l->receive_async (block, representative, amount, [wallet_l, block] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
if (block_a == nullptr)
|
||||
{
|
||||
|
|
|
@ -145,9 +145,9 @@ class node;
|
|||
class wallet : public std::enable_shared_from_this <rai::wallet>
|
||||
{
|
||||
public:
|
||||
std::unique_ptr <rai::block> change_action (rai::account const &, rai::account const &);
|
||||
std::unique_ptr <rai::block> receive_action (rai::send_block const &, rai::account const &, rai::uint128_union const &);
|
||||
std::unique_ptr <rai::block> send_action (rai::account const &, rai::account const &, rai::uint128_t const &);
|
||||
std::shared_ptr <rai::block> change_action (rai::account const &, rai::account const &);
|
||||
std::shared_ptr <rai::block> receive_action (rai::send_block const &, rai::account const &, rai::uint128_union const &);
|
||||
std::shared_ptr <rai::block> send_action (rai::account const &, rai::account const &, rai::uint128_t const &);
|
||||
wallet (bool &, rai::transaction &, rai::node &, std::string const &);
|
||||
wallet (bool &, rai::transaction &, rai::node &, std::string const &, std::string const &);
|
||||
void enter_initial_password ();
|
||||
|
@ -161,11 +161,11 @@ public:
|
|||
bool import (std::string const &, std::string const &);
|
||||
void serialize (std::string &);
|
||||
bool change_sync (rai::account const &, rai::account const &);
|
||||
void change_async (rai::account const &, rai::account const &, std::function <void (std::unique_ptr <rai::block>)> const &);
|
||||
bool receive_sync (rai::send_block const &, rai::account const &, rai::uint128_t const &);
|
||||
void receive_async (rai::send_block const &, rai::account const &, rai::uint128_t const &, std::function <void (std::unique_ptr <rai::block>)> const &);
|
||||
void change_async (rai::account const &, rai::account const &, std::function <void (std::shared_ptr <rai::block>)> const &);
|
||||
bool receive_sync (std::shared_ptr <rai::block>, rai::account const &, rai::uint128_t const &);
|
||||
void receive_async (std::shared_ptr <rai::block>, rai::account const &, rai::uint128_t const &, std::function <void (std::shared_ptr <rai::block>)> const &);
|
||||
rai::block_hash send_sync (rai::account const &, rai::account const &, rai::uint128_t const &);
|
||||
void send_async (rai::account const &, rai::account const &, rai::uint128_t const &, std::function <void (std::unique_ptr <rai::block>)> const &);
|
||||
void send_async (rai::account const &, rai::account const &, rai::uint128_t const &, std::function <void (std::shared_ptr <rai::block>)> const &);
|
||||
void work_generate (rai::account const &, rai::block_hash const &);
|
||||
void work_update (MDB_txn *, rai::account const &, rai::block_hash const &, uint64_t);
|
||||
uint64_t work_fetch (MDB_txn *, rai::account const &, rai::block_hash const &);
|
||||
|
|
|
@ -597,7 +597,7 @@ void rai_qt::block_viewer::rebroadcast_action (rai::uint256_union const & hash_a
|
|||
auto block (wallet.node.store.block_get (transaction, hash_a));
|
||||
if (block != nullptr)
|
||||
{
|
||||
wallet.node.network.republish_block (*block);
|
||||
wallet.node.network.republish_block (std::move (block));
|
||||
auto successor (wallet.node.store.block_successor (transaction, hash_a));
|
||||
if (!successor.is_zero ())
|
||||
{
|
||||
|
@ -897,7 +897,7 @@ void rai_qt::wallet::start ()
|
|||
{
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->wallet_m->send_async (this_l->account, account_l, actual, [this_w] (std::unique_ptr <rai::block> block_a)
|
||||
this_l->wallet_m->send_async (this_l->account, account_l, actual, [this_w] (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
|
|
|
@ -122,36 +122,36 @@ boost::filesystem::path rai::working_path ()
|
|||
return result;
|
||||
}
|
||||
|
||||
size_t rai::unique_ptr_block_hash::operator () (std::unique_ptr <rai::block> const & block_a) const
|
||||
size_t rai::shared_ptr_block_hash::operator () (std::shared_ptr <rai::block> const & block_a) const
|
||||
{
|
||||
auto hash (block_a->hash ());
|
||||
auto result (static_cast <size_t> (hash.qwords [0]));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool rai::unique_ptr_block_hash::operator () (std::unique_ptr <rai::block> const & lhs, std::unique_ptr <rai::block> const & rhs) const
|
||||
bool rai::shared_ptr_block_hash::operator () (std::shared_ptr <rai::block> const & lhs, std::shared_ptr <rai::block> const & rhs) const
|
||||
{
|
||||
return *lhs == *rhs;
|
||||
}
|
||||
|
||||
// Sum the weights for each vote and return the winning block with its vote tally
|
||||
std::pair <rai::uint128_t, std::unique_ptr <rai::block>> rai::ledger::winner (MDB_txn * transaction_a, rai::votes const & votes_a)
|
||||
std::pair <rai::uint128_t, std::shared_ptr <rai::block>> rai::ledger::winner (MDB_txn * transaction_a, rai::votes const & votes_a)
|
||||
{
|
||||
auto tally_l (tally (transaction_a, votes_a));
|
||||
auto existing (tally_l.begin ());
|
||||
return std::make_pair (existing->first, existing->second->clone ());
|
||||
return std::make_pair (existing->first, existing->second);
|
||||
}
|
||||
|
||||
std::map <rai::uint128_t, std::unique_ptr <rai::block>, std::greater <rai::uint128_t>> rai::ledger::tally (MDB_txn * transaction_a, rai::votes const & votes_a)
|
||||
std::map <rai::uint128_t, std::shared_ptr <rai::block>, std::greater <rai::uint128_t>> rai::ledger::tally (MDB_txn * transaction_a, rai::votes const & votes_a)
|
||||
{
|
||||
std::unordered_map <std::unique_ptr <block>, rai::uint128_t, rai::unique_ptr_block_hash, rai::unique_ptr_block_hash> totals;
|
||||
std::unordered_map <std::shared_ptr <block>, rai::uint128_t, rai::shared_ptr_block_hash, rai::shared_ptr_block_hash> totals;
|
||||
// Construct a map of blocks -> vote total.
|
||||
for (auto & i: votes_a.rep_votes)
|
||||
{
|
||||
auto existing (totals.find (i.second));
|
||||
if (existing == totals.end ())
|
||||
{
|
||||
totals.insert (std::make_pair (i.second->clone (), 0));
|
||||
totals.insert (std::make_pair (i.second, 0));
|
||||
existing = totals.find (i.second);
|
||||
assert (existing != totals.end ());
|
||||
}
|
||||
|
@ -159,18 +159,18 @@ std::map <rai::uint128_t, std::unique_ptr <rai::block>, std::greater <rai::uint1
|
|||
existing->second += weight_l;
|
||||
}
|
||||
// Construction a map of vote total -> block in decreasing order.
|
||||
std::map <rai::uint128_t, std::unique_ptr <rai::block>, std::greater <rai::uint128_t>> result;
|
||||
std::map <rai::uint128_t, std::shared_ptr <rai::block>, std::greater <rai::uint128_t>> result;
|
||||
for (auto & i: totals)
|
||||
{
|
||||
result [i.second] = i.first->clone ();
|
||||
result [i.second] = i.first;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
rai::votes::votes (rai::block const & block_a) :
|
||||
id (block_a.root ())
|
||||
rai::votes::votes (std::shared_ptr <rai::block> block_a) :
|
||||
id (block_a->root ())
|
||||
{
|
||||
rep_votes.insert (std::make_pair (rai::not_an_account, block_a.clone ()));
|
||||
rep_votes.insert (std::make_pair (rai::not_an_account, block_a));
|
||||
}
|
||||
|
||||
rai::tally_result rai::votes::vote (rai::vote const & vote_a)
|
||||
|
@ -181,7 +181,7 @@ rai::tally_result rai::votes::vote (rai::vote const & vote_a)
|
|||
{
|
||||
// Vote on this block hasn't been seen from rep before
|
||||
result = rai::tally_result::vote;
|
||||
rep_votes.insert (std::make_pair (vote_a.account, vote_a.block->clone ()));
|
||||
rep_votes.insert (std::make_pair (vote_a.account, vote_a.block));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ rai::tally_result rai::votes::vote (rai::vote const & vote_a)
|
|||
{
|
||||
// Rep changed their vote
|
||||
result = rai::tally_result::changed;
|
||||
existing->second = vote_a.block->clone ();
|
||||
existing->second = vote_a.block;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -558,11 +558,6 @@ rai::account rai::receive_block::representative () const
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::receive_block::clone () const
|
||||
{
|
||||
return std::unique_ptr <rai::block> (new rai::receive_block (*this));
|
||||
}
|
||||
|
||||
rai::block_type rai::receive_block::type () const
|
||||
{
|
||||
return rai::block_type::receive;
|
||||
|
@ -805,11 +800,6 @@ bool rai::send_block::operator == (rai::block const & other_a) const
|
|||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::send_block::clone () const
|
||||
{
|
||||
return std::unique_ptr <rai::block> (new rai::send_block (*this));
|
||||
}
|
||||
|
||||
rai::block_type rai::send_block::type () const
|
||||
{
|
||||
return rai::block_type::send;
|
||||
|
@ -1050,11 +1040,6 @@ void rai::open_block::visit (rai::block_visitor & visitor_a) const
|
|||
visitor_a.open_block (*this);
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::open_block::clone () const
|
||||
{
|
||||
return std::unique_ptr <rai::block> (new rai::open_block (*this));
|
||||
}
|
||||
|
||||
rai::block_type rai::open_block::type () const
|
||||
{
|
||||
return rai::block_type::open;
|
||||
|
@ -1269,11 +1254,6 @@ void rai::change_block::visit (rai::block_visitor & visitor_a) const
|
|||
visitor_a.change_block (*this);
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::change_block::clone () const
|
||||
{
|
||||
return std::unique_ptr <rai::block> (new rai::change_block (*this));
|
||||
}
|
||||
|
||||
rai::block_type rai::change_block::type () const
|
||||
{
|
||||
return rai::block_type::change;
|
||||
|
@ -3258,7 +3238,7 @@ transaction (transaction_a)
|
|||
|
||||
rai::vote::vote (rai::vote const & other_a) :
|
||||
sequence (other_a.sequence),
|
||||
block (other_a.block->clone ()),
|
||||
block (other_a.block),
|
||||
account (other_a.account),
|
||||
signature (other_a.signature)
|
||||
{
|
||||
|
@ -3285,9 +3265,9 @@ rai::vote::vote (bool & error_a, rai::stream & stream_a, rai::block_type type_a)
|
|||
}
|
||||
}
|
||||
|
||||
rai::vote::vote (rai::account const & account_a, rai::raw_key const & prv_a, uint64_t sequence_a, std::unique_ptr <rai::block> block_a) :
|
||||
rai::vote::vote (rai::account const & account_a, rai::raw_key const & prv_a, uint64_t sequence_a, std::shared_ptr <rai::block> block_a) :
|
||||
sequence (sequence_a),
|
||||
block (std::move (block_a)),
|
||||
block (block_a),
|
||||
account (account_a),
|
||||
signature (rai::sign_message (prv_a, account_a, hash ()))
|
||||
{
|
||||
|
|
|
@ -57,14 +57,13 @@ public:
|
|||
virtual void serialize_json (std::string &) const = 0;
|
||||
virtual void visit (rai::block_visitor &) const = 0;
|
||||
virtual bool operator == (rai::block const &) const = 0;
|
||||
virtual std::unique_ptr <rai::block> clone () const = 0;
|
||||
virtual rai::block_type type () const = 0;
|
||||
};
|
||||
class unique_ptr_block_hash
|
||||
class shared_ptr_block_hash
|
||||
{
|
||||
public:
|
||||
size_t operator () (std::unique_ptr <rai::block> const &) const;
|
||||
bool operator () (std::unique_ptr <rai::block> const &, std::unique_ptr <rai::block> const &) const;
|
||||
size_t operator () (std::shared_ptr <rai::block> const &) const;
|
||||
bool operator () (std::shared_ptr <rai::block> const &, std::shared_ptr <rai::block> const &) const;
|
||||
};
|
||||
std::unique_ptr <rai::block> deserialize_block (MDB_val const &);
|
||||
std::unique_ptr <rai::block> deserialize_block (rai::stream &);
|
||||
|
@ -101,7 +100,6 @@ public:
|
|||
bool deserialize (rai::stream &);
|
||||
bool deserialize_json (boost::property_tree::ptree const &);
|
||||
void visit (rai::block_visitor &) const override;
|
||||
std::unique_ptr <rai::block> clone () const override;
|
||||
rai::block_type type () const override;
|
||||
bool operator == (rai::block const &) const override;
|
||||
bool operator == (rai::send_block const &) const;
|
||||
|
@ -139,7 +137,6 @@ public:
|
|||
bool deserialize (rai::stream &);
|
||||
bool deserialize_json (boost::property_tree::ptree const &);
|
||||
void visit (rai::block_visitor &) const override;
|
||||
std::unique_ptr <rai::block> clone () const override;
|
||||
rai::block_type type () const override;
|
||||
bool operator == (rai::block const &) const override;
|
||||
bool operator == (rai::receive_block const &) const;
|
||||
|
@ -179,7 +176,6 @@ public:
|
|||
bool deserialize (rai::stream &);
|
||||
bool deserialize_json (boost::property_tree::ptree const &);
|
||||
void visit (rai::block_visitor &) const override;
|
||||
std::unique_ptr <rai::block> clone () const override;
|
||||
rai::block_type type () const override;
|
||||
bool operator == (rai::block const &) const override;
|
||||
bool operator == (rai::open_block const &) const;
|
||||
|
@ -217,7 +213,6 @@ public:
|
|||
bool deserialize (rai::stream &);
|
||||
bool deserialize_json (boost::property_tree::ptree const &);
|
||||
void visit (rai::block_visitor &) const override;
|
||||
std::unique_ptr <rai::block> clone () const override;
|
||||
rai::block_type type () const override;
|
||||
bool operator == (rai::block const &) const override;
|
||||
bool operator == (rai::change_block const &) const;
|
||||
|
@ -460,12 +455,12 @@ public:
|
|||
vote () = default;
|
||||
vote (rai::vote const &);
|
||||
vote (bool &, rai::stream &, rai::block_type);
|
||||
vote (rai::account const &, rai::raw_key const &, uint64_t, std::unique_ptr <rai::block>);
|
||||
vote (rai::account const &, rai::raw_key const &, uint64_t, std::shared_ptr <rai::block>);
|
||||
rai::uint256_union hash () const;
|
||||
rai::vote_result validate (MDB_txn *, rai::block_store &) const;
|
||||
// Vote round sequence number
|
||||
uint64_t sequence;
|
||||
std::unique_ptr <rai::block> block;
|
||||
std::shared_ptr <rai::block> block;
|
||||
// Account that's voting
|
||||
rai::account account;
|
||||
// Signature of sequence + block hash
|
||||
|
@ -480,20 +475,20 @@ enum class tally_result
|
|||
class votes
|
||||
{
|
||||
public:
|
||||
votes (rai::block const &);
|
||||
votes (std::shared_ptr <rai::block>);
|
||||
rai::tally_result vote (rai::vote const &);
|
||||
// Root block of fork
|
||||
rai::block_hash id;
|
||||
// All votes received by account
|
||||
std::unordered_map <rai::account, std::unique_ptr <rai::block>> rep_votes;
|
||||
std::unordered_map <rai::account, std::shared_ptr <rai::block>> rep_votes;
|
||||
};
|
||||
class ledger
|
||||
{
|
||||
public:
|
||||
ledger (rai::block_store &, rai::uint128_t const & = 0);
|
||||
std::pair <rai::uint128_t, std::unique_ptr <rai::block>> winner (MDB_txn *, rai::votes const & votes_a);
|
||||
std::pair <rai::uint128_t, std::shared_ptr <rai::block>> winner (MDB_txn *, rai::votes const & votes_a);
|
||||
// Map of weight -> associated block, ordered greatest to least
|
||||
std::map <rai::uint128_t, std::unique_ptr <rai::block>, std::greater <rai::uint128_t>> tally (MDB_txn *, rai::votes const &);
|
||||
std::map <rai::uint128_t, std::shared_ptr <rai::block>, std::greater <rai::uint128_t>> tally (MDB_txn *, rai::votes const &);
|
||||
rai::account account (MDB_txn *, rai::block_hash const &);
|
||||
rai::uint128_t amount (MDB_txn *, rai::block_hash const &);
|
||||
rai::uint128_t balance (MDB_txn *, rai::block_hash const &);
|
||||
|
|
|
@ -189,9 +189,9 @@ TEST (node, fork_storm)
|
|||
auto send_result (system.nodes [i]->process (send));
|
||||
ASSERT_EQ (rai::process_result::progress, send_result.code);
|
||||
rai::keypair rep;
|
||||
rai::open_block open (previous, rep.pub, key.pub, key.prv, key.pub, 0);
|
||||
system.nodes [i]->generate_work (open);
|
||||
auto open_result (system.nodes [i]->process (open));
|
||||
auto open (std::make_shared <rai::open_block> (previous, rep.pub, key.pub, key.prv, key.pub, 0));
|
||||
system.nodes [i]->generate_work (*open);
|
||||
auto open_result (system.nodes [i]->process (*open));
|
||||
ASSERT_EQ (rai::process_result::progress, open_result.code);
|
||||
system.nodes [i]->network.republish_block (open);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue