protocols

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolVersion string = "0.0.33"

ProtocolVersion Current supported Protocol Version Not all of this is supported, but this was the current version at the time This library was started

Variables

This section is empty.

Functions

func DecodeMessageData

func DecodeMessageData(bytes []byte, v interface{}) error

DecodeMessageData decodes a message.data into the given interface

func MakeMessageBytes

func MakeMessageBytes(messageType ProtocolMessageType, data interface{}) ([]byte, error)

MakeMessageBytes calls MakeMessage and converts everything down to bytes

Types

type Capability

type Capability struct {
	Capability CapabilityType `streamable:""`
	Value      string         `streamable:""`
}

Capability reflects a capability of the peer This represents the Tuple that exists in the Python code

type CapabilityType

type CapabilityType uint16

CapabilityType is an internal references for types of capabilities

const (
	// CapabilityTypeBase just means it supports the chia protocol at mainnet
	CapabilityTypeBase CapabilityType = 1
)

type Handshake

type Handshake struct {
	NetworkID       string       `streamable:""`
	ProtocolVersion string       `streamable:""`
	SoftwareVersion string       `streamable:""`
	ServerPort      uint16       `streamable:""`
	NodeType        NodeType     `streamable:""`
	Capabilities    []Capability `streamable:""` // List[Tuple[uint16, str]]
}

Handshake is a handshake message

type Message

type Message struct {
	ProtocolMessageType ProtocolMessageType `streamable:""`
	ID                  mo.Option[uint16]   `streamable:""`
	Data                []byte              `streamable:""`
}

Message is a protocol message

func DecodeMessage

func DecodeMessage(bytes []byte) (*Message, error)

DecodeMessage is a helper function to quickly decode bytes to Message

func MakeMessage

func MakeMessage(messageType ProtocolMessageType, data interface{}) (*Message, error)

MakeMessage makes a new Message with the given data

func (*Message) DecodeData

func (m *Message) DecodeData(v interface{}) error

DecodeData decodes the data in the message to the provided type

type NodeType

type NodeType uint8

NodeType is the type of peer (farmer, full node, etc) Source for node types is chia/server/outbound_messages.py

const (
	// NodeTypeFullNode NodeType for full node
	NodeTypeFullNode NodeType = 1

	// NodeTypeHarvester NodeType for Harvester
	NodeTypeHarvester NodeType = 2

	// NodeTypeFarmer NodeType for Farmer
	NodeTypeFarmer NodeType = 3

	// NodeTypeTimelord NodeType for Timelord
	NodeTypeTimelord NodeType = 4

	// NodeTypeIntroducer NodeType for Introducer
	NodeTypeIntroducer NodeType = 5

	// NodeTypeWallet NodeType for Wallet
	NodeTypeWallet NodeType = 6
)

type Plot added in v0.5.0

type Plot struct {
	Filename               string                     `json:"filename"`
	Size                   uint8                      `json:"size"`
	PlotID                 types.Bytes32              `json:"plot_id"`
	PoolPublicKey          mo.Option[types.G1Element] `json:"pool_public_key"`
	PoolContractPuzzleHash mo.Option[types.Bytes32]   `json:"pool_contract_puzzle_hash"`
	PlotPublicKey          types.G1Element            `json:"plot_public_key"`
	FileSize               uint64                     `json:"file_size"`
	TimeModified           types.Timestamp            `json:"time_modified"`
	CompressionLevel       mo.Option[uint8]           `json:"compression_level"`
}

Plot is the plot definition in the harvester protocol https://github.com/Chia-Network/chia-blockchain/blob/main/chia/protocols/harvester_protocol.py#L78

type ProtocolMessageType

type ProtocolMessageType uint8

ProtocolMessageType corresponds to ProtocolMessageTypes in Chia

const (
	// ProtocolMessageTypeHandshake Handshake
	ProtocolMessageTypeHandshake ProtocolMessageType = 1

	// ProtocolMessageTypeRequestPeers request_peers
	ProtocolMessageTypeRequestPeers ProtocolMessageType = 43

	// ProtocolMessageTypeRespondPeers respond_peers
	ProtocolMessageTypeRespondPeers ProtocolMessageType = 44
)

type RequestPeers

type RequestPeers struct{}

RequestPeers is an empty struct

type RespondPeers

type RespondPeers struct {
	PeerList []types.TimestampedPeerInfo `streamable:""`
}

RespondPeers is the format for the request_peers response

Jump to

Keyboard shortcuts

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