Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
[etl_optimisations] block_traversal -> header_traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethen Pociask committed Nov 2, 2023
1 parent 46842a7 commit b6569a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions internal/etl/registry/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
notFoundMsg = "not found"
)

type BlockTraversal struct {
type HeaderTraversal struct {
n core.Network
cUUID core.CUUID
pUUID core.PUUID
Expand All @@ -31,7 +31,7 @@ type BlockTraversal struct {
stats metrics.Metricer
}

func NewBlockTraversal(ctx context.Context, cfg *core.ClientConfig,
func NewHeaderTraversal(ctx context.Context, cfg *core.ClientConfig,
opts ...component.Option) (component.Component, error) {
clients, err := client.FromContext(ctx)
if err != nil {
Expand All @@ -56,7 +56,7 @@ func NewBlockTraversal(ctx context.Context, cfg *core.ClientConfig,
// TODO - Support network confirmation counts
ht := ix_node.NewHeaderTraversal(node, startHeader, big.NewInt(0))

bt := &BlockTraversal{
bt := &HeaderTraversal{
n: cfg.Network,
client: node,
traversal: ht,
Expand All @@ -73,11 +73,11 @@ func NewBlockTraversal(ctx context.Context, cfg *core.ClientConfig,
return reader, nil
}

func (bt *BlockTraversal) Height() (*big.Int, error) {
func (bt *HeaderTraversal) Height() (*big.Int, error) {
return bt.traversal.LastHeader().Number, nil
}

func (bt *BlockTraversal) Backfill(start, end *big.Int, consumer chan core.TransitData) error {
func (bt *HeaderTraversal) Backfill(start, end *big.Int, consumer chan core.TransitData) error {
for i := start; i.Cmp(end) < 0; i.Add(i, big.NewInt(batchSize)) {
end := big.NewInt(0).Add(i, big.NewInt(batchSize))

Expand All @@ -99,7 +99,7 @@ func (bt *BlockTraversal) Backfill(start, end *big.Int, consumer chan core.Trans
}

// Loop ...
func (bt *BlockTraversal) Loop(ctx context.Context, consumer chan core.TransitData) error {
func (bt *HeaderTraversal) Loop(ctx context.Context, consumer chan core.TransitData) error {
ticker := time.NewTicker(1 * time.Second)

recent, err := bt.client.BlockHeaderByNumber(nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/etl/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewRegistry() Registry {
Addressing: false,
DataType: core.BlockHeader,
ComponentType: core.Reader,
Constructor: NewBlockTraversal,
Constructor: NewHeaderTraversal,

Dependencies: noDeps(),
Sk: noState(),
Expand Down

0 comments on commit b6569a0

Please sign in to comment.