Skip to content

Commit

Permalink
Sync activations on boot and optimize tx pump
Browse files Browse the repository at this point in the history
  • Loading branch information
kacpersaw committed Mar 13, 2024
1 parent 74018bc commit 7dd2f2b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ func (c *Collector) Run() error {
c.listener.RecalculateEpochStats()
}

err = c.syncActivations()
if err != nil {
return errors.Join(errors.New("cannot sync activations"), err)
}

g := new(errgroup.Group)
g.Go(func() error {
err := c.syncStatusPump()
Expand Down
1 change: 1 addition & 0 deletions collector/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func (c *Collector) syncAllRewards() error {

func (c *Collector) syncActivations() error {
received := c.listener.GetLastActivationReceived()
log.Info("Syncing activations from %d", received)

err := c.dbClient.GetAtxsReceivedAfter(c.db, received, func(atx *types.VerifiedActivationTx) bool {
c.listener.OnActivation(atx)
Expand Down
6 changes: 5 additions & 1 deletion collector/txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
)

func (c *Collector) transactionsPump() error {
epochNumLayers := c.listener.GetEpochNumLayers()
lastLayer := c.listener.GetLastLayer(context.Background())
currentEpoch := lastLayer / epochNumLayers

req := pb.TransactionResultsRequest{
Start: 1,
Start: (currentEpoch - 2) * epochNumLayers,
Watch: true,
}

Expand Down

0 comments on commit 7dd2f2b

Please sign in to comment.