dex_session

package
v0.51.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package dex_session provides shared block transfer session logic for DEX backends. It wraps a bifrost stream/packet.Session with chunked block transfer, size validation, and hash verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockTransfer

type BlockTransfer struct {

	// RequestId pairs requests with responses.
	RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"requestId,omitempty"`
	// Ref is the block reference (set in Init message).
	Ref *block.BlockRef `protobuf:"bytes,2,opt,name=ref,proto3" json:"ref,omitempty"`
	// TotalSize is the total block size in bytes (set in Init message).
	// Receiver rejects if over max_block_size.
	TotalSize uint64 `protobuf:"varint,3,opt,name=total_size,json=totalSize,proto3" json:"totalSize,omitempty"`
	// Data is the chunk payload (up to chunk_size bytes).
	Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
	// Complete indicates this is the last chunk for this block.
	Complete bool `protobuf:"varint,5,opt,name=complete,proto3" json:"complete,omitempty"`
	// Error is set if the transfer failed.
	Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"`
	// Cancel requests the sender to skip this block.
	Cancel bool `protobuf:"varint,7,opt,name=cancel,proto3" json:"cancel,omitempty"`
	// contains filtered or unexported fields
}

BlockTransfer is a message on a block transfer stream. Embedded as a submessage in backend-specific wire protocols.

func (*BlockTransfer) CloneMessageVT

func (m *BlockTransfer) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*BlockTransfer) CloneVT

func (m *BlockTransfer) CloneVT() *BlockTransfer

func (*BlockTransfer) EqualMessageVT

func (this *BlockTransfer) EqualMessageVT(thatMsg any) bool

func (*BlockTransfer) EqualVT

func (this *BlockTransfer) EqualVT(that *BlockTransfer) bool

func (*BlockTransfer) GetCancel

func (x *BlockTransfer) GetCancel() bool

func (*BlockTransfer) GetComplete

func (x *BlockTransfer) GetComplete() bool

func (*BlockTransfer) GetData

func (x *BlockTransfer) GetData() []byte

func (*BlockTransfer) GetError

func (x *BlockTransfer) GetError() string

func (*BlockTransfer) GetRef

func (x *BlockTransfer) GetRef() *block.BlockRef

func (*BlockTransfer) GetRequestId

func (x *BlockTransfer) GetRequestId() uint64

func (*BlockTransfer) GetTotalSize

func (x *BlockTransfer) GetTotalSize() uint64

func (*BlockTransfer) MarshalJSON

func (x *BlockTransfer) MarshalJSON() ([]byte, error)

MarshalJSON marshals the BlockTransfer to JSON.

func (*BlockTransfer) MarshalProtoJSON

func (x *BlockTransfer) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the BlockTransfer message to JSON.

func (*BlockTransfer) MarshalProtoText

func (x *BlockTransfer) MarshalProtoText() string

func (*BlockTransfer) MarshalToSizedBufferVT

func (m *BlockTransfer) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*BlockTransfer) MarshalToVT

func (m *BlockTransfer) MarshalToVT(dAtA []byte) (int, error)

func (*BlockTransfer) MarshalVT

func (m *BlockTransfer) MarshalVT() (dAtA []byte, err error)

func (*BlockTransfer) ProtoMessage

func (*BlockTransfer) ProtoMessage()

func (*BlockTransfer) Reset

func (x *BlockTransfer) Reset()

func (*BlockTransfer) SizeVT

func (m *BlockTransfer) SizeVT() (n int)

func (*BlockTransfer) String

func (x *BlockTransfer) String() string

func (*BlockTransfer) UnmarshalJSON

func (x *BlockTransfer) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the BlockTransfer from JSON.

func (*BlockTransfer) UnmarshalProtoJSON

func (x *BlockTransfer) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the BlockTransfer message from JSON.

func (*BlockTransfer) UnmarshalVT

func (m *BlockTransfer) UnmarshalVT(dAtA []byte) error

type DexSession

type DexSession struct {
	// contains filtered or unexported fields
}

DexSession wraps a stream/packet.Session for chunked block transfer.

func NewDexSession

func NewDexSession(stream io.ReadWriteCloser, chunkSize int, maxBlockSize uint64) *DexSession

NewDexSession constructs a new DexSession wrapping the given stream. If chunkSize <= 0, uses the default (1KB). If maxBlockSize <= 0, uses the default (10MB).

func (*DexSession) Close

func (d *DexSession) Close() error

Close closes the underlying session stream.

func (*DexSession) ReadMessage

func (d *DexSession) ReadMessage() (*BlockTransfer, error)

ReadMessage reads the next BlockTransfer from the stream.

func (*DexSession) ReceiveBlock

func (d *DexSession) ReceiveBlock(maxBlockSize uint64) (uint64, *block.BlockRef, []byte, error)

ReceiveBlock reads a complete block from the stream (Init + chunks). If maxBlockSize is 0, uses the session default. Returns the request ID, block reference, assembled data, and any error.

func (*DexSession) SendBlock

func (d *DexSession) SendBlock(requestID uint64, ref *block.BlockRef, data []byte) error

SendBlock sends a complete block as Init + chunked data messages. The data is always chunked even if it fits in a single chunk.

func (*DexSession) SendCancel

func (d *DexSession) SendCancel(requestID uint64) error

SendCancel sends a cancel message for the given request.

func (*DexSession) SendChunk

func (d *DexSession) SendChunk(requestID uint64, data []byte, complete bool) error

SendChunk sends a data chunk message.

func (*DexSession) SendError

func (d *DexSession) SendError(requestID uint64, errMsg string) error

SendError sends an error message for the given request.

func (*DexSession) SendInit

func (d *DexSession) SendInit(requestID uint64, ref *block.BlockRef, totalSize uint64) error

SendInit sends an init message with the block reference and total size.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL