-
Notifications
You must be signed in to change notification settings - Fork 217
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
Added deployments tests from bitcoin #451
Conversation
if let Some(ref header) = result { | ||
self.block = BlockRef::Hash(header.previous_header_hash.clone()); | ||
} | ||
let result = self.block.take().and_then(|block| self.headers.block_header(block)); |
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.
Otherwise it was infinite iterator - don't know if this was intended. Just noticed.
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.
It would finish. For genesis block, line 24 would return Hash(0000)
and next iteration would not find header for that block :)
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.
Yes, but what if in first next()
call, result is None
? Then self.block will never change && it would became infinite. I've actually stumbled upon this.
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.
first None
result should always indicate the end of iteration :)
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.
My bad - you're right :) I'll try to remember original reason && revert if this isn't actually a fix.
I'm pretty sure I've seen infinite iterator in construction this_iterator.take(11)
- all 11 elements were the same.
But now I think that it possibly was because of bug in my Headers implementation
// number is number of block which is currently validating | ||
// => it is not in database | ||
// we need to make all checks for previous blocks | ||
let number = number.saturating_sub(1); |
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.
That was the main reason of panic previously
also fixed typo in HeaderCheck |
if let Some(ref header) = result { | ||
self.block = BlockRef::Hash(header.previous_header_hash.clone()); | ||
} | ||
let result = self.block.take().and_then(|block| self.headers.block_header(block)); |
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.
It would finish. For genesis block, line 24 would return Hash(0000)
and next iteration would not find header for that block :)
(self.header.raw.version < 3 && self.height >= self.consensus_params.bip65_height) || | ||
(self.header.raw.version < 4 && self.height >= self.consensus_params.bip66_height) { | ||
(self.header.raw.version < 3 && self.height >= self.consensus_params.bip66_height) || | ||
(self.header.raw.version < 4 && self.height >= self.consensus_params.bip65_height) { |
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.
great catch!
It is a part of #443 fix - I'll return
expect()
call after synchronizing testnet