Skip to content
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): Introduce Fragment type to FullSync strategy #4320

Open
EclesioMeloJunior opened this issue Nov 7, 2024 · 0 comments · May be fixed by #4274
Open

chore(dot/sync): Introduce Fragment type to FullSync strategy #4320

EclesioMeloJunior opened this issue Nov 7, 2024 · 0 comments · May be fixed by #4274
Assignees

Comments

@EclesioMeloJunior
Copy link
Member

EclesioMeloJunior commented Nov 7, 2024

Issue summary

  • Create the Fragment type, which is a specialized type that deals with chain of blocks[]*types.BlockData which represents a raw chain of blocks to be imported.

The struct only holds the chain of blocks

type Fragment struct {
	chain []*types.BlockData
}

// Filter returns a new fragments with blocks that satisfies the predicate p
func (f *Fragment) Filter(p func(*types.BlockData) bool) *Fragment

// Find return the first occurrence of a types.BlockData that
// satisfies the predicate p
func (f *Fragment) Find(p func(*types.BlockData) bool) *types.BlockData

// Last returns the first block in the fragment or nil otherwise
func (f *Fragment) First() *types.BlockData

// Last returns the last block in the fragment or nil otherwise
func (f *Fragment) Last() *types.BlockData

// Len returns the amount of blocks in the fragment
func (f *Fragment) Len() int

// Iter returns an iterator of the blocks in the fragment
// it enables the caller to use range keyword in the Fragment instance
func (f *Fragment) Iter() iter.Seq[*types.BlockData]

// Concat returns a new fragment containing the concatenation
// between this fragment and the given as argument fragment
func (f *Fragment) Concat(snd *Fragment) *Fragment 

The goal is to constraint the the previously type [][]*types.BlockData (slice of slice of blocks data) in a []*Fragments (slice of fragments) with a better API to simplify the usage/manipulation/checks in the full sync strategy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant