Fixed pending block response (#8200)

This commit is contained in:
Giulio rebuffo 2023-09-14 22:13:41 +02:00 committed by GitHub
parent 9c47978472
commit 1f77fee04a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,10 +96,19 @@ func (s *EthBackendServer) Version(context.Context, *emptypb.Empty) (*types2.Ver
return EthBackendAPIVersion, nil
}
func (s *EthBackendServer) PendingBlock(_ context.Context, _ *emptypb.Empty) (*remote.PendingBlockReply, error) {
func (s *EthBackendServer) PendingBlock(ctx context.Context, _ *emptypb.Empty) (*remote.PendingBlockReply, error) {
pendingBlock := s.latestBlockBuiltStore.BlockBuilt()
if pendingBlock == nil {
return nil, nil
tx, err := s.db.BeginRo(ctx)
if err != nil {
return nil, err
}
defer tx.Rollback()
// use latest
pendingBlock, err = s.blockReader.CurrentBlock(tx)
if err != nil {
return nil, err
}
}
blockRlp, err := rlp.EncodeToBytes(pendingBlock)