From 77dde8a370ae378d53ae7d653cab3fedefa165fc Mon Sep 17 00:00:00 2001 From: Niclas Blomberg Date: Mon, 12 Feb 2024 17:49:30 +0100 Subject: [PATCH] feat: handle bidtrace 404 --- datastore/auction_api.go | 6 ++++++ datastore/datastore.go | 1 + 2 files changed, 7 insertions(+) diff --git a/datastore/auction_api.go b/datastore/auction_api.go index 446a2710..6f29ce24 100644 --- a/datastore/auction_api.go +++ b/datastore/auction_api.go @@ -27,6 +27,7 @@ func GetPayloadContents(slot uint64, proposerPubkey, blockHash string) (*builder if err != nil { return nil, err } + defer resp.Body.Close() if resp.StatusCode == 404 { return nil, ErrExecutionPayloadNotFound @@ -60,6 +61,11 @@ func GetBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTrac if err != nil { return nil, err } + defer resp.Body.Close() + + if resp.StatusCode == 404 { + return nil, ErrBidTraceNotFound + } body, err := io.ReadAll(resp.Body) if err != nil { diff --git a/datastore/datastore.go b/datastore/datastore.go index 4e5e9e0b..19508b88 100644 --- a/datastore/datastore.go +++ b/datastore/datastore.go @@ -21,6 +21,7 @@ import ( ) var ErrExecutionPayloadNotFound = errors.New("execution payload not found") +var ErrBidTraceNotFound = errors.New("bidtrace not found") type GetHeaderResponseKey struct { Slot uint64