diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index 5fc10808dd..387acf1153 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -247,16 +247,28 @@ void nano::block_processor::add_impl (std::shared_ptr block) { if (block->type () == nano::block_type::state || block->type () == nano::block_type::open) { - state_block_signature_verification.add ({ block }); - } - else - { + auto & epochs = node.ledger.constants.epochs; + if (epochs.is_epoch_link (block->link ())) + { + nano::lock_guard guard{ mutex }; + blocks.emplace_back (block); + } + else if (!nano::validate_message (block->account (), block->hash (), block->block_signature ())) { nano::lock_guard guard{ mutex }; blocks.emplace_back (block); } - condition.notify_all (); + else + { + // Incorrect signature + } } + else + { + nano::lock_guard guard{ mutex }; + blocks.emplace_back (block); + } + condition.notify_all (); } auto nano::block_processor::process_batch (nano::unique_lock & lock_a) -> std::deque diff --git a/nano/node/vote_processor.cpp b/nano/node/vote_processor.cpp index fd6d5696cb..8dbc1005ce 100644 --- a/nano/node/vote_processor.cpp +++ b/nano/node/vote_processor.cpp @@ -134,36 +134,12 @@ bool nano::vote_processor::vote (std::shared_ptr const & vote_a, std void nano::vote_processor::verify_votes (decltype (votes) const & votes_a) { - auto size (votes_a.size ()); - std::vector messages; - messages.reserve (size); - std::vector hashes; - hashes.reserve (size); - std::vector lengths (size, sizeof (nano::block_hash)); - std::vector pub_keys; - pub_keys.reserve (size); - std::vector signatures; - signatures.reserve (size); - std::vector verifications; - verifications.resize (size); for (auto const & vote : votes_a) { - hashes.push_back (vote.first->hash ()); - messages.push_back (hashes.back ().bytes.data ()); - pub_keys.push_back (vote.first->account.bytes.data ()); - signatures.push_back (vote.first->signature.bytes.data ()); - } - nano::signature_check_set check = { size, messages.data (), lengths.data (), pub_keys.data (), signatures.data (), verifications.data () }; - checker.verify (check); - auto i (0); - for (auto const & vote : votes_a) - { - debug_assert (verifications[i] == 1 || verifications[i] == 0); - if (verifications[i] == 1) + if (!nano::validate_message (vote.first->account, vote.first->hash (), vote.first->signature)) { vote_blocking (vote.first, vote.second, true); } - ++i; } }