Skip to content

Commit

Permalink
use resolveBlockRange
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann committed Dec 13, 2024
1 parent 81cf80c commit 7780811
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions rpc/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,9 @@ func (h *Handler) SubscribeEvents(ctx context.Context, fromAddr *felt.Felt, keys
return nil, ErrTooManyKeysInFilter
}

var requestedHeader *core.Header
headHeader, err := h.bcReader.HeadsHeader()
if err != nil {
return nil, ErrInternal.CloneWithData(err.Error())
}

if blockID == nil {
requestedHeader = headHeader
} else {
if blockID.Pending {
return nil, ErrCallOnPending
}

var rpcErr *jsonrpc.Error
requestedHeader, rpcErr = h.blockHeaderByID(blockID)
if rpcErr != nil {
return nil, rpcErr
}

if headHeader.Number >= maxBlocksBack && requestedHeader.Number <= headHeader.Number-maxBlocksBack {
return nil, ErrTooManyBlocksBack
}
requestedHeader, headHeader, rpcErr := h.resolveBlockRange(blockID)
if rpcErr != nil {
return nil, rpcErr
}

id := h.idgen()
Expand Down

0 comments on commit 7780811

Please sign in to comment.