Skip to content

ts-p2p: add a typed decoder for the two-layer JSON wire format #250

Description

@zcoolz

@bsv/teranode-listener hands callbacks the raw GossipSub bytes (Uint8Array). Those bytes are a two-layer JSON structure: a message-bus envelope { name, data: base64 } (from go-p2p-message-bus) wrapping a topic-specific JSON payload (from services/p2p/message_types.go). Every consumer currently has to reimplement that decode, including the PascalCase vs snake_case difference between block/subtree/rejected-tx and node_status.

Proposal: an opt-in typed decoder in the package, decodeMessage() / tryDecodeMessage() plus typed payload interfaces, and a decodeMessages: true listener flag so callbacks receive a typed DecodedMessage instead of raw bytes. Fully backward compatible (defaults to off).

I have a working implementation verified field-for-field against the current message_types.go and will open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions