Skip to content

Commit

Permalink
update Solana last scanned block more frequently
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Dec 17, 2024
1 parent 6730285 commit 9a9584d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion zetaclient/chains/solana/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,24 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error {
ob.WithLastTxScanned(lastSig.String())
}

// query last finalized slot
lastSlot, err := ob.solClient.GetSlot(ctx, rpc.CommitmentFinalized)
if err != nil {
ob.Logger().Inbound.Err(err).Msg("unable to get last slot")
}

// get all signatures for the gateway address since last scanned signature
lastSig := solana.MustSignatureFromBase58(ob.LastTxScanned())
signatures, err := solanarpc.GetSignaturesForAddressUntil(ctx, ob.solClient, ob.gatewayID, lastSig, pageLimit)
if err != nil {
ob.Logger().Inbound.Err(err).Msg("error GetSignaturesForAddressUntil")
return err
}
if len(signatures) > 0 {

// update metrics if no new signatures found
if len(signatures) == 0 {
ob.WithLastBlockScanned(lastSlot)
} else {
ob.Logger().Inbound.Info().Msgf("ObserveInbound: got %d signatures for chain %d", len(signatures), chainID)
}

Expand Down

0 comments on commit 9a9584d

Please sign in to comment.