-
Notifications
You must be signed in to change notification settings - Fork 112
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
chore(dot/sync): add Fragment
struct for chain of blocks
#4274
base: development
Are you sure you want to change the base?
Conversation
Fragment
struct for chain of blocks
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.
just a few nits, can be merged as is imho
// disjoint set and return the fragment concatenated with the chain argument | ||
func (u *unreadyBlocks) updateDisjointFragments(chain []*types.BlockData) ([]*types.BlockData, bool) { | ||
// connects to a disjoint fragment, and returns a ne fragment | ||
func (u *unreadyBlocks) updateDisjointFragment(chain *Fragment) (*Fragment, bool) { |
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.
func (u *unreadyBlocks) updateDisjointFragment(chain *Fragment) (*Fragment, bool) { | |
func (u *unreadyBlocks) updateDisjointFragments(chain *Fragment) (*Fragment, bool) { |
I would keep the plural here. Alternatively, update the doc comment as well.
// LowerThanOrEqHighestFinalized returns true if the fragment contains | ||
// a block that has a number lower than highest finalized number | ||
func LowerThanOrEqHighestFinalized(highestFinalizedNumber uint) func(*Fragment) bool { |
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.
nit:
// LowerThanOrEqHighestFinalized returns true if the fragment contains | |
// a block that has a number lower than highest finalized number | |
func LowerThanOrEqHighestFinalized(highestFinalizedNumber uint) func(*Fragment) bool { | |
// LowerThanOrEq returns a function that returns true if the fragment contains | |
// a block that has a number lower than or equal to the passed in number | |
func LowerThanOrEq(blockNumber uint) func(*Fragment) bool { |
The function is more general than the name and doc comment suggests. It could be called with something other than the highest finalized number.
// connects to a disjoint fragment, if so we remove the fragment from the | ||
// disjoint set and return the fragment concatenated with the chain argument | ||
func (u *unreadyBlocks) updateDisjointFragments(chain []*types.BlockData) ([]*types.BlockData, bool) { | ||
// connects to a disjoint fragment, and returns a ne fragment |
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.
// connects to a disjoint fragment, and returns a ne fragment | |
// connects to a disjoint fragment, and returns a new fragment |
func (f *Fragment) Iter() iter.Seq[*types.BlockData] { | ||
return func(yield func(*types.BlockData) bool) { | ||
for _, bd := range f.chain { | ||
yield(bd) |
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 should check the yield function result
yield(bd) | |
if !yield(bd){ | |
return | |
} |
@@ -43,6 +44,16 @@ func (f *Fragment) Find(p func(*types.BlockData) bool) *types.BlockData { | |||
return nil | |||
} | |||
|
|||
// Last returns the first block in the fragment or nil otherwise |
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.
// Last returns the first block in the fragment or nil otherwise | |
// First returns the first block in the fragment or nil otherwise |
Changes
[][]*types.BlockData
Tests
Issues
Fragment
type toFullSync
strategy #4320