From dcfd9036988d0c5a3cb306dac3abfb26cd5f0f0d Mon Sep 17 00:00:00 2001 From: Kaloyan Tanev Date: Tue, 19 Aug 2025 16:21:43 +0300 Subject: [PATCH] Add X-timeout-ms header --- server/constants.go | 2 ++ server/get_header.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/server/constants.go b/server/constants.go index c4273a8c..0b2ac029 100644 --- a/server/constants.go +++ b/server/constants.go @@ -9,6 +9,8 @@ const ( HeaderUserAgent = "User-Agent" // Header which communicates when a request was sent. Used to measure latency. HeaderDateMilliseconds = "Date-Milliseconds" + // Header which communicates timeout set by client. Used to tweak block creation delay together with Date-Milliseconds. + HeaderTimeoutMs = "X-Timeout-Ms" MediaTypeJSON = "application/json" MediaTypeOctetStream = "application/octet-stream" diff --git a/server/get_header.go b/server/get_header.go index 942acf9b..ee1aec8c 100644 --- a/server/get_header.go +++ b/server/get_header.go @@ -7,6 +7,7 @@ import ( "io" "mime" "net/http" + "strconv" "sync" "time" @@ -89,6 +90,7 @@ func (m *BoostService) getHeader(log *logrus.Entry, slot phase0.Slot, pubkey, pa req.Header.Set(HeaderKeySlotUID, slotUID.String()) req.Header.Set(HeaderUserAgent, userAgent) req.Header.Set(HeaderDateMilliseconds, startTime) + req.Header.Set(HeaderTimeoutMs, strconv.FormatInt(m.httpClientGetHeader.Timeout.Milliseconds(), 10)) // Send the request log.Debug("requesting header")