-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Motivation
MEV-Share's event stream uses Server-Sent Events (SSE), not WebSocket. eth.zig currently has ws_transport.zig and http_transport.zig but no SSE transport. This blocks a full MEV-Share client.
SSE is also used by other Ethereum tooling (some RPC providers, block explorers), so this is a generally useful transport.
Specification
New file: src/sse_transport.zig
pub const SseTransport = struct {
/// Open a persistent HTTP connection and parse the SSE event stream.
/// Calls `callback` for each complete event.
pub fn subscribe(
allocator: std.mem.Allocator,
url: []const u8,
headers: []const std.http.Header,
callback: *const fn (event: SseEvent) void,
) !void
pub const SseEvent = struct {
id: ?[]const u8,
event: ?[]const u8, // event type ("tx", "bundle", etc.)
data: []const u8, // JSON payload
};
};Wire format
SSE is a text protocol over a persistent HTTP/1.1 connection:
data: {"hash":"0xabc...","logs":[...]}\n
\n
id: 42\n
event: bundle\n
data: {"hash":"0xdef..."}\n
\n
Parser needs to handle:
- Multi-line
data:fields (concatenate with\n) id:andevent:fields- Blank line as event delimiter
- Reconnect on connection drop (respect
retry:field) Last-Event-IDheader on reconnect
MEV-Share event stream URL
https://mev-share.flashbots.net/api/v1/events (mainnet)
Auth header: X-Flashbots-Signature: 0x<address>:0x<sig> (same scheme as flashbots.zig).
Relationship
This is a prerequisite for mev_share.zig client (event streaming) — see companion issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request