refactor!(stump): Move updated data to its own function#81
refactor!(stump): Move updated data to its own function#81Davidson-Souza wants to merge 3 commits intomit-dci:mainfrom
Conversation
8eb9f98 to
bfd09ed
Compare
38e545e to
427a309
Compare
|
@Davidson-Souza do you have a Floresta branch using this PR? |
No, waiting on Jose's pr with swift sync stuff |
|
It's time 🎅🏻 |
|
Nit on the commit description: the |
cf2c8a4 to
78d99d9
Compare
Before this change, `modify` would return the data needed to update a proof for the new block. This requires additional internal computation and extra allocations. During IBD we may never use this, since proof update is only meant for updating a few blocks worth of changes. Now there's a method specific to pull the modify_data, and `modify` itself will only return a new Stump. When refactoring the addition function, I've modified it a little to allow a smarter one with a very nice property: it can pretend that it added a node, but actually represent it as deleted. The goal here is to do a Swift Sync-style protocol where you don't need deletions. If a txout is already spent, you give an empty hash (BitcoinNodeHash::empty()). This will be exactly equivalent as giving this txo's hash and later on calling delete for with this txo's hash. However, it does this with only one call to modify and doesn't require proofs to achieve that. This is an API breaking change, as modify now only returns one parameter, otherwise the behavior stays unchanged.
78d99d9 to
d86c319
Compare
| proof: &Proof<Hash>, | ||
| ) -> Result<(Self, UpdateData<Hash>), StumpError> { | ||
| let (intermediate, mut computed_roots) = self.remove(del_hashes, proof)?; | ||
| ) -> Result<Self, StumpError> { |
There was a problem hiding this comment.
Why no longer return UpdateData, a rebase issue? What is it for btw, I wonder
There was a problem hiding this comment.
Before this change, modify would return the data needed to update a proof for the new block. This requires additional internal computation and extra allocations. During IBD we may never use this, since proof update is only meant for updating a few blocks worth of changes. Now there's a method specific to pull the modify_data, and modify itself will only return a new Stump.
Before this change,
modifywould return the data needed to update a proof for the new block. This requires additional internal computation and extra allocations. During IBD we may never use this, since proof update is only meant for updating a few blocks worth of changes. Now there's a method specific to pull the modify_data, andmodifyitself will only return a new Stump.When refactoring the addition function, I've modified it a little to allow a smarter one with a very nice property: it can pretend that it added a node, but actually represent it as deleted. The goal here is to do a Swift Sync-style protocol where you don't need deletions.
If a txout is already spent, you give an empty hash (BitcoinNodeHash::empty()). This will be exactly equivalent as giving this txo's hash and later on calling delete for with this txo's hash. However, it does this with only one call to modify and doesn't require proofs to achieve that.
This is an API breaking change, as modify now only returns one parameter, otherwise the behavior stays unchanged.