Skip to content

Commit

Permalink
Fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushinDaniil committed Jan 29, 2025
1 parent 30c12a0 commit 5d919e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rpc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func (h *Handler) MethodsV0_7() ([]jsonrpc.Method, string) { //nolint: funlen
{
Name: "starknet_subscribeNewHeads",
Params: []jsonrpc.Parameter{{Name: "block", Optional: true}},
Handler: h.SubscribeNewHeadsV0_7,
Handler: h.SubscribeNewHeads,
},
{
Name: "starknet_unsubscribe",
Expand Down
15 changes: 3 additions & 12 deletions rpc/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,6 @@ func sendEvents(ctx context.Context, w jsonrpc.Conn, events []*blockchain.Filter

// SubscribeNewHeads creates a WebSocket stream which will fire events when a new block header is added.
func (h *Handler) SubscribeNewHeads(ctx context.Context, blockID *BlockID) (*SubscriptionID, *jsonrpc.Error) {
return h.subscribeNewHeads(ctx, blockID, V0_8)
}

func (h *Handler) SubscribeNewHeadsV0_7(ctx context.Context, blockID *BlockID) (*SubscriptionID, *jsonrpc.Error) {
return h.subscribeNewHeads(ctx, blockID, V0_7)
}

func (h *Handler) subscribeNewHeads(ctx context.Context, blockID *BlockID, rpcVersion version) (*SubscriptionID, *jsonrpc.Error) {
w, ok := jsonrpc.ConnFromContext(ctx)
if !ok {
return nil, jsonrpc.Err(jsonrpc.MethodNotFound, nil)
Expand Down Expand Up @@ -383,7 +375,7 @@ func (h *Handler) subscribeNewHeads(ctx context.Context, blockID *BlockID, rpcVe
var wg conc.WaitGroup

wg.Go(func() {
if err := h.sendHistoricalHeaders(subscriptionCtx, startHeader, latestHeader, w, id, rpcVersion); err != nil {
if err := h.sendHistoricalHeaders(subscriptionCtx, startHeader, latestHeader, w, id); err != nil {
h.log.Errorw("Error sending old headers", "err", err)
return
}
Expand All @@ -394,7 +386,7 @@ func (h *Handler) subscribeNewHeads(ctx context.Context, blockID *BlockID, rpcVe
})

wg.Go(func() {
h.processNewHeaders(subscriptionCtx, headerSub, w, id, rpcVersion)
h.processNewHeaders(subscriptionCtx, headerSub, w, id)
})

wg.Wait()
Expand Down Expand Up @@ -562,7 +554,6 @@ func (h *Handler) sendHistoricalHeaders(
startHeader, latestHeader *core.Header,
w jsonrpc.Conn,
id uint64,
rpcVersion version,
) error {
var (
err error
Expand Down Expand Up @@ -590,7 +581,7 @@ func (h *Handler) sendHistoricalHeaders(
}
}

func (h *Handler) processNewHeaders(ctx context.Context, headerSub *feed.Subscription[*core.Header], w jsonrpc.Conn, id uint64, rpcVersion version) {
func (h *Handler) processNewHeaders(ctx context.Context, headerSub *feed.Subscription[*core.Header], w jsonrpc.Conn, id uint64) {
for {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 5d919e9

Please sign in to comment.