-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unchecked cleanup #3600
Unchecked cleanup #3600
Changes from all commits
f442049
531ad50
2f8f7ac
a155347
0597340
60c1a36
0ca58c1
0d49186
27a2fbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3308,16 +3308,18 @@ TEST (node, block_processor_signatures) | |
.build_shared (); | ||
send4->signature.bytes[32] ^= 0x1; | ||
// Invalid signature bit (force) | ||
auto send5 = builder.make_block () | ||
.account (nano::dev::genesis_key.pub) | ||
.previous (send3->hash ()) | ||
.representative (nano::dev::genesis_key.pub) | ||
.balance (nano::dev::constants.genesis_amount - 5 * nano::Gxrb_ratio) | ||
.link (key3.pub) | ||
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) | ||
.work (*node1.work_generate_blocking (send3->hash ())) | ||
.build_shared (); | ||
send5->signature.bytes[31] ^= 0x1; | ||
std::shared_ptr<nano::block> send5 = builder.make_block () | ||
.account (nano::dev::genesis_key.pub) | ||
.previous (send3->hash ()) | ||
.representative (nano::dev::genesis_key.pub) | ||
.balance (nano::dev::constants.genesis_amount - 5 * nano::Gxrb_ratio) | ||
.link (key3.pub) | ||
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) | ||
.work (*node1.work_generate_blocking (send3->hash ())) | ||
.build_shared (); | ||
auto signature = send5->block_signature (); | ||
signature.bytes[31] ^= 0x1; | ||
send5->signature_set (signature); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it's more clean to get the signature, touch it, then set it back, but was there a functional problem with changing it in-place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're holding a pointer to nano::block instead of the specific block type, the signature field is no longer directly accessible. |
||
// Invalid signature to unchecked | ||
{ | ||
auto transaction (node1.store.tx_begin_write ()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This clean up looks good, but since you touched the lines anyway, why not
auto block = std::make_shared...
? Not really important but just in the spirit ofif cleaning it up, clean it all the way
:D.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one specifically is because std::shared_ptrnano::send_block won't implicitly convert to unchecked_info when passed to unchecked_store::put. It won't do an upcast and also an implicit conversion.