Skip to content

Commit

Permalink
rpc: Move Astrid snapshot reader (#12142)
Browse files Browse the repository at this point in the history
Moves spanProducersReader code down to the function that covers all use
cases. Not all RPCs call `GetSnapshot`, which lead to errors when using
Astrid.
  • Loading branch information
shohamc1 authored Oct 1, 2024
1 parent 6253b98 commit 0ab5dc7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions turbo/jsonrpc/bor_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,6 @@ func (api *BorImpl) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) {
return nil, errUnknownBlock
}

if api.spanProducersReader != nil {
validatorSet, err := api.spanProducersReader.Producers(ctx, header.Number.Uint64())
if err != nil {
return nil, err
}

snap := &Snapshot{
Number: header.Number.Uint64(),
Hash: header.Hash(),
ValidatorSet: validatorSet,
}

return snap, nil
}

// init consensus db
borEngine, err := api.bor()
if err != nil {
Expand Down Expand Up @@ -568,6 +553,21 @@ func snapshot(ctx context.Context, api *BorImpl, db kv.Tx, borDb kv.Tx, header *
number := header.Number.Uint64()
hash := header.Hash()

if api.spanProducersReader != nil {
validatorSet, err := api.spanProducersReader.Producers(ctx, header.Number.Uint64())
if err != nil {
return nil, err
}

snap := &Snapshot{
Number: header.Number.Uint64(),
Hash: header.Hash(),
ValidatorSet: validatorSet,
}

return snap, nil
}

for snap == nil {
// If an on-disk checkpoint snapshot can be found, use that
if number%checkpointInterval == 0 {
Expand Down

0 comments on commit 0ab5dc7

Please sign in to comment.