Skip to content

Commit

Permalink
refactor(consensus): separate sending block parts from "pick part" lo…
Browse files Browse the repository at this point in the history
…gic (cometbft#2663)

This was done by @ebuchman as part of a refactoring spree :-)

The goal of this is to improve testability of `gossipDataRoutine` by
separating out the logic for picking which block part to send. We
introduced a new pure function, `pickPartToSend`, which returns a block
part, and then call the new `SendPartSetHasPart` method to send it and
update the peer state. This greatly simplifies the loop in
`gossipDataRoutine`, and allows the `pickPartToSend` function to be
independently tested.

Note for reviewers:
* This PR is built on top of cometbft#2659
* This is pure refactoring, no logic change was intended.
* This PR can be reviewed commit by commit

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Sergio Mena <sergio@informal.systems>
Co-authored-by: Ethan Buchman <ethan@coinculture.info>
  • Loading branch information
3 people authored Apr 17, 2024
1 parent 8883f15 commit 163f2d5
Showing 1 changed file with 276 additions and 245 deletions.
Loading

0 comments on commit 163f2d5

Please sign in to comment.