Constructing confirm_ack with vote instead of individual components.
This commit is contained in:
parent
9e0e71e97c
commit
1e340841ef
7 changed files with 20 additions and 9 deletions
|
@ -76,7 +76,8 @@ TEST (message, publish_serialization)
|
|||
TEST (message, confirm_ack_serialization)
|
||||
{
|
||||
rai::keypair key1;
|
||||
rai::confirm_ack con1 (key1.pub, key1.prv, 0, std::unique_ptr <rai::block> (new rai::send_block (0, 1, 2, key1.prv, 4, 5)));
|
||||
rai::vote vote (key1.pub, key1.prv, 0, std::unique_ptr <rai::block> (new rai::send_block (0, 1, 2, key1.prv, 4, 5)));
|
||||
rai::confirm_ack con1 (vote);
|
||||
std::vector <uint8_t> bytes;
|
||||
{
|
||||
rai::vectorstream stream1 (bytes);
|
||||
|
@ -87,4 +88,4 @@ TEST (message, confirm_ack_serialization)
|
|||
rai::confirm_ack con2 (error, stream2);
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (con1, con2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,8 @@ TEST (message_parser, exact_confirm_ack_size)
|
|||
test_visitor visitor;
|
||||
rai::message_parser parser (visitor, system.work);
|
||||
auto block (std::unique_ptr <rai::send_block> (new rai::send_block (1, 1, 2, rai::keypair ().prv, 4, system.work.generate (1))));
|
||||
rai::confirm_ack message (0, rai::keypair ().prv, 0, std::move (block));
|
||||
rai::vote vote (0, rai::keypair ().prv, 0, std::move (block));
|
||||
rai::confirm_ack message (vote);
|
||||
std::vector <uint8_t> bytes;
|
||||
{
|
||||
rai::vectorstream stream (bytes);
|
||||
|
|
|
@ -270,7 +270,8 @@ TEST (receivable_processor, confirm_insufficient_pos)
|
|||
});
|
||||
}
|
||||
rai::keypair key1;
|
||||
rai::confirm_ack con1 (key1.pub, key1.prv, 0, block1.clone ());
|
||||
rai::vote vote (key1.pub, key1.prv, 0, block1.clone ());
|
||||
rai::confirm_ack con1 (vote);
|
||||
node1.process_message (con1, node1.network.endpoint ());
|
||||
}
|
||||
|
||||
|
@ -289,7 +290,8 @@ TEST (receivable_processor, confirm_sufficient_pos)
|
|||
node_l->process_confirmed (block_a);
|
||||
});
|
||||
}
|
||||
rai::confirm_ack con1 (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.clone ());
|
||||
rai::confirm_ack con1 (vote);
|
||||
node1.process_message (con1, node1.network.endpoint ());
|
||||
}
|
||||
|
||||
|
|
|
@ -367,9 +367,9 @@ vote (error_a, stream_a, block_type ())
|
|||
{
|
||||
}
|
||||
|
||||
rai::confirm_ack::confirm_ack (rai::account const & account_a, rai::raw_key const & prv_a, uint64_t sequence_a, std::unique_ptr <rai::block> block_a) :
|
||||
rai::confirm_ack::confirm_ack (rai::vote & vote_a) :
|
||||
message (rai::message_type::confirm_ack),
|
||||
vote (account_a, prv_a, sequence_a, std::move (block_a))
|
||||
vote (std::move (vote_a))
|
||||
{
|
||||
block_type_set (vote.block->type ());
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ class confirm_ack : public message
|
|||
{
|
||||
public:
|
||||
confirm_ack (bool &, rai::stream &);
|
||||
confirm_ack (rai::account const &, rai::raw_key const &, uint64_t, std::unique_ptr <rai::block>);
|
||||
confirm_ack (rai::vote &);
|
||||
bool deserialize (rai::stream &) override;
|
||||
void serialize (rai::stream &) override;
|
||||
void visit (rai::message_visitor &) const override;
|
||||
|
|
|
@ -1197,7 +1197,13 @@ void rai::gap_cache::purge_old ()
|
|||
|
||||
void rai::network::confirm_block (rai::raw_key const & prv, rai::public_key const & pub, std::unique_ptr <rai::block> block_a, uint64_t sequence_a, rai::endpoint const & endpoint_a)
|
||||
{
|
||||
rai::confirm_ack confirm (pub, prv, sequence_a, std::move (block_a));
|
||||
rai::vote vote (pub, prv, sequence_a, std::move (block_a));
|
||||
confirm_block (vote, endpoint_a);
|
||||
}
|
||||
|
||||
void rai::network::confirm_block (rai::vote & vote_a, rai::endpoint const & endpoint_a)
|
||||
{
|
||||
rai::confirm_ack confirm (vote_a);
|
||||
std::shared_ptr <std::vector <uint8_t>> bytes (new std::vector <uint8_t>);
|
||||
{
|
||||
rai::vectorstream stream (*bytes);
|
||||
|
|
|
@ -273,6 +273,7 @@ public:
|
|||
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_block (rai::raw_key const &, rai::public_key const &, std::unique_ptr <rai::block>, uint64_t, rai::endpoint const &);
|
||||
void confirm_block (rai::vote &, 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 &);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue