-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add edge case handling and tests for initConsistentUtreexoState #230
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -586,6 +586,15 @@ func upgradeUtreexoState(cfg *UtreexoConfig, p *utreexo.MapPollard, | |
func (us *UtreexoState) initConsistentUtreexoState(chain *blockchain.BlockChain, | ||
savedHash, tipHash *chainhash.Hash, tipHeight int32) error { | ||
|
||
// Handle nil tipHash | ||
if tipHash == nil { | ||
return fmt.Errorf("tipHash is nil, cannot initialize Utreexo state") | ||
} | ||
|
||
// Handle negative tipHeight | ||
if tipHeight < 0 { | ||
return nil | ||
} | ||
Comment on lines
+589
to
+597
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.
|
||
// This is a new accumulator state that we're working with. | ||
var empty chainhash.Hash | ||
if tipHeight == -1 && tipHash.IsEqual(&empty) { | ||
|
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.
We handle both of the cases literally just below at line 600.
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 intention was to handle cases where either
tipHash == nil
ortipHeight < 0
happens on its own, which the logic at line 600 doesn’t cover.