-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/main' into call-many-fix
- Loading branch information
Showing
21 changed files
with
251 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package heimdall | ||
|
||
import ( | ||
"context" | ||
|
||
libcommon "github.com/erigontech/erigon-lib/common" | ||
"github.com/erigontech/erigon-lib/log/v3" | ||
"github.com/erigontech/erigon/polygon/bor/valset" | ||
) | ||
|
||
type Reader struct { | ||
logger log.Logger | ||
store ServiceStore | ||
spanBlockProducersTracker *spanBlockProducersTracker | ||
} | ||
|
||
// AssembleReader creates and opens the MDBX store. For use cases where the store is only being read from. Must call Close. | ||
func AssembleReader(ctx context.Context, calculateSprintNumber CalculateSprintNumberFunc, dataDir string, tmpDir string, logger log.Logger) (*Reader, error) { | ||
store := NewMdbxServiceStore(logger, dataDir, tmpDir) | ||
|
||
err := store.Prepare(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return NewReader(calculateSprintNumber, store, logger), nil | ||
} | ||
|
||
func NewReader(calculateSprintNumber CalculateSprintNumberFunc, store ServiceStore, logger log.Logger) *Reader { | ||
return &Reader{ | ||
logger: logger, | ||
store: store, | ||
spanBlockProducersTracker: newSpanBlockProducersTracker(logger, calculateSprintNumber, store.SpanBlockProducerSelections()), | ||
} | ||
} | ||
|
||
func (r *Reader) Span(ctx context.Context, id uint64) (*Span, bool, error) { | ||
return r.store.Spans().Entity(ctx, id) | ||
} | ||
|
||
func (r *Reader) CheckpointsFromBlock(ctx context.Context, startBlock uint64) (Waypoints, error) { | ||
entities, err := r.store.Checkpoints().RangeFromBlockNum(ctx, startBlock) | ||
return libcommon.SliceMap(entities, castEntityToWaypoint[*Checkpoint]), err | ||
} | ||
|
||
func (r *Reader) MilestonesFromBlock(ctx context.Context, startBlock uint64) (Waypoints, error) { | ||
entities, err := r.store.Milestones().RangeFromBlockNum(ctx, startBlock) | ||
return libcommon.SliceMap(entities, castEntityToWaypoint[*Milestone]), err | ||
} | ||
|
||
func (r *Reader) Producers(ctx context.Context, blockNum uint64) (*valset.ValidatorSet, error) { | ||
return r.spanBlockProducersTracker.Producers(ctx, blockNum) | ||
} | ||
|
||
func (r *Reader) Close() { | ||
r.store.Close() | ||
} |
Oops, something went wrong.