Skip to content

Commit

Permalink
feat: use finality as the syncer
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Jul 29, 2024
1 parent 256f80a commit c4fec21
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/0xPolygon/cdk/localbridgesync"
"github.com/0xPolygon/cdk/log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
)
Expand All @@ -39,6 +38,7 @@ type AggSender struct {

originNetwork uint32
lastSentCertificateBlock *uint64
finality *big.Int
sendInterval types.Duration
}

Expand All @@ -61,9 +61,15 @@ func New(
return nil, err
}

finality, err := cfg.LocalBridgeSyncer.BlockFinalityType.ToBlockNum()
if err != nil {
return nil, err
}

return &AggSender{
db: db,
syncer: syncer,
finality: finality,
client: l2Client,
aggLayerClient: aggLayerClient,
originNetwork: cfg.OriginNetwork,
Expand All @@ -90,7 +96,7 @@ func (a *AggSender) sendCertificates(ctx context.Context) {
continue
}

lastFinalizedBlock, err := a.client.HeaderByNumber(ctx, big.NewInt(int64(rpc.FinalizedBlockNumber)))
lastFinalizedBlock, err := a.client.HeaderByNumber(ctx, a.finality)
if err != nil {
log.Error("Error getting block number", "err", err)
continue
Expand Down

0 comments on commit c4fec21

Please sign in to comment.