Adding manual block confirmation function.
This commit is contained in:
parent
06d0c0d000
commit
303c3cdcaa
3 changed files with 30 additions and 0 deletions
|
@ -1475,3 +1475,25 @@ TEST (node, online_reps)
|
|||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
}
|
||||
|
||||
TEST (node, block_confirm)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::genesis genesis;
|
||||
system.nodes [0]->ledger.state_block_parse_canary = genesis.hash ();
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
auto send1 (std::make_shared <rai::state_block> (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.nodes [0]->generate_work (genesis.hash ())));
|
||||
{
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (transaction, *send1).code);
|
||||
}
|
||||
system.nodes [0]->block_confirm (send1);
|
||||
ASSERT_TRUE (system.nodes [0]->active.confirmed.empty ());
|
||||
auto iterations (0);
|
||||
while (system.nodes [0]->active.confirmed.empty ())
|
||||
{
|
||||
system.poll ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2394,6 +2394,13 @@ void rai::node::add_initial_peers ()
|
|||
{
|
||||
}
|
||||
|
||||
void rai::node::block_confirm (std::shared_ptr <rai::block> block_a)
|
||||
{
|
||||
rai::transaction transaction (store.environment, nullptr, false);
|
||||
active.start (transaction, block_a);
|
||||
network.broadcast_confirm_req (block_a);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class confirmed_visitor : public rai::block_visitor
|
||||
|
|
|
@ -549,6 +549,7 @@ public:
|
|||
uint64_t generate_work (rai::uint256_union const &);
|
||||
void generate_work (rai::uint256_union const &, std::function<void(uint64_t)>);
|
||||
void add_initial_peers ();
|
||||
void block_confirm (std::shared_ptr <rai::block>);
|
||||
boost::asio::io_service & service;
|
||||
rai::node_config config;
|
||||
rai::alarm & alarm;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue