gateway

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 14 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	GenesisID  types.BlockID
	UniqueID   UniqueID
	NetAddress string
}

A Header contains various peer metadata which is exchanged during the gateway handshake.

type Object added in v0.2.1

type Object interface {
	// contains filtered or unexported methods
}

An Object can be sent or received via RPC.

func ObjectForID added in v0.2.1

func ObjectForID(id types.Specifier) Object

ObjectForID returns the object type corresponding to the given RPC ID.

type OutlineTransaction added in v0.1.12

type OutlineTransaction struct {
	Hash          types.Hash256
	Transaction   *types.Transaction
	V2Transaction *types.V2Transaction
}

An OutlineTransaction identifies a transaction by its full hash. The actual transaction data may or may not be present.

type RPCDiscoverIP

type RPCDiscoverIP struct {
	IP string
	// contains filtered or unexported fields
}

RPCDiscoverIP requests the caller's externally-visible IP address.

type RPCRelayHeader

type RPCRelayHeader struct {
	Header types.BlockHeader
	// contains filtered or unexported fields
}

RPCRelayHeader relays a header.

type RPCRelayTransactionSet

type RPCRelayTransactionSet struct {
	Transactions []types.Transaction
	// contains filtered or unexported fields
}

RPCRelayTransactionSet relays a transaction set.

type RPCRelayV2BlockOutline added in v0.1.12

type RPCRelayV2BlockOutline struct {
	Block V2BlockOutline
	// contains filtered or unexported fields
}

RPCRelayV2BlockOutline relays a v2 block outline.

type RPCRelayV2Header added in v0.1.12

type RPCRelayV2Header struct {
	Header types.BlockHeader
	// contains filtered or unexported fields
}

RPCRelayV2Header relays a v2 block header.

type RPCRelayV2TransactionSet added in v0.1.12

type RPCRelayV2TransactionSet struct {
	Index        types.ChainIndex
	Transactions []types.V2Transaction
	// contains filtered or unexported fields
}

RPCRelayV2TransactionSet relays a v2 transaction set.

type RPCSendBlk

type RPCSendBlk struct {
	ID    types.BlockID
	Block types.Block
}

RPCSendBlk requests a single block.

type RPCSendBlocks

type RPCSendBlocks struct {
	History [32]types.BlockID
	Blocks  []types.Block
}

RPCSendBlocks requests a set of blocks.

type RPCSendBlocksMoreAvailable added in v0.2.1

type RPCSendBlocksMoreAvailable struct {
	MoreAvailable bool
	// contains filtered or unexported fields
}

RPCSendBlocksMoreAvailable indicates whether more blocks are available.

type RPCSendCheckpoint added in v0.1.12

type RPCSendCheckpoint struct {
	Index types.ChainIndex

	Block types.Block
	State consensus.State
}

RPCSendCheckpoint requests a checkpoint.

type RPCSendTransactions added in v0.1.12

type RPCSendTransactions struct {
	Index  types.ChainIndex
	Hashes []types.Hash256

	Transactions   []types.Transaction
	V2Transactions []types.V2Transaction
}

RPCSendTransactions requests a subset of a block's transactions.

type RPCSendV2Blocks added in v0.1.12

type RPCSendV2Blocks struct {
	History   []types.BlockID
	Max       uint64
	Blocks    []types.Block
	Remaining uint64
}

RPCSendV2Blocks requests a set of blocks.

type RPCShareNodes

type RPCShareNodes struct {
	Peers []string
	// contains filtered or unexported fields
}

RPCShareNodes requests a list of potential peers.

type Stream added in v0.2.1

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

A Stream provides a multiplexed stream for the Sia gateway protocol.

func (*Stream) Close added in v0.2.1

func (s *Stream) Close() error

Close closes the stream.

func (*Stream) ReadID added in v0.2.1

func (s *Stream) ReadID() (id types.Specifier, err error)

ReadID reads an RPC ID from the stream.

func (*Stream) ReadRequest added in v0.2.1

func (s *Stream) ReadRequest(r Object) error

ReadRequest reads a request from the stream into r.

func (*Stream) ReadResponse added in v0.2.1

func (s *Stream) ReadResponse(r Object) error

ReadResponse reads a response from the stream into r.

func (*Stream) SetDeadline added in v0.2.1

func (s *Stream) SetDeadline(t time.Time) error

SetDeadline implements net.Conn.

func (*Stream) WriteID added in v0.2.1

func (s *Stream) WriteID(r Object) error

WriteID writes the RPC ID of r to the stream.

func (*Stream) WriteRequest added in v0.2.1

func (s *Stream) WriteRequest(r Object) error

WriteRequest writes the request field of r to the stream.

func (*Stream) WriteResponse added in v0.2.1

func (s *Stream) WriteResponse(r Object) error

WriteResponse writes the response field of r to the stream.

type Transport added in v0.2.1

type Transport struct {
	UniqueID UniqueID
	Version  string
	Addr     string
	// contains filtered or unexported fields
}

A Transport provides a multiplexing transport for the Sia gateway protocol.

func Accept added in v0.1.12

func Accept(conn net.Conn, ourHeader Header) (*Transport, error)

Accept reciprocates the gateway handshake with a peer.

func Dial added in v0.1.12

func Dial(conn net.Conn, ourHeader Header) (*Transport, error)

Dial initiates the gateway handshake with a peer.

func (*Transport) AcceptStream added in v0.2.1

func (t *Transport) AcceptStream() (*Stream, error)

AcceptStream accepts an incoming multiplexed stream.

func (*Transport) Close added in v0.2.1

func (t *Transport) Close() error

Close closes the underlying connection.

func (*Transport) DialStream added in v0.2.1

func (t *Transport) DialStream() (*Stream, error)

DialStream opens a new multiplexed stream.

func (*Transport) SupportsV2 added in v0.2.1

func (t *Transport) SupportsV2() bool

SupportsV2 returns true if the transport supports v2 RPCs.

type UniqueID

type UniqueID [8]byte

A UniqueID is a randomly-generated nonce that helps prevent self-connections and double-connections.

func GenerateUniqueID

func GenerateUniqueID() (id UniqueID)

GenerateUniqueID returns a random UniqueID.

type V2BlockOutline added in v0.1.12

type V2BlockOutline struct {
	Height       uint64
	ParentID     types.BlockID
	Nonce        uint64
	Timestamp    time.Time
	MinerAddress types.Address
	Transactions []OutlineTransaction
}

A V2BlockOutline represents a Block with one or more transactions omitted. The original block can be reconstructed by matching the transaction hashes to transactions present in the txpool, or requesting them from peers.

func OutlineBlock added in v0.1.12

func OutlineBlock(b types.Block, txns []types.Transaction, v2txns []types.V2Transaction) V2BlockOutline

OutlineBlock returns a block outline for b that omits the specified transactions.

func (*V2BlockOutline) Complete added in v0.1.12

func (bo *V2BlockOutline) Complete(cs consensus.State, txns []types.Transaction, v2txns []types.V2Transaction) (types.Block, []types.Hash256)

Complete attempts to reconstruct the original block using the supplied transactions. If the block cannot be fully reconstructed, it returns the hashes of the missing transactions.

func (V2BlockOutline) ID added in v0.1.12

ID returns a hash that uniquely identifies the block.

func (V2BlockOutline) Missing added in v0.1.12

func (bo V2BlockOutline) Missing() (missing []types.Hash256)

Missing returns the hashes of transactions that are missing from the block.

func (*V2BlockOutline) RemoveTransactions added in v0.1.12

func (bo *V2BlockOutline) RemoveTransactions(txns []types.Transaction, v2txns []types.V2Transaction)

RemoveTransactions removes the specified transactions from the block.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳