Documentation
¶
Index ¶
Constants ¶
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 ¶
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 ¶
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 ¶
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 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 RespondPeers ¶
type RespondPeers struct {
PeerList []types.TimestampedPeerInfo `streamable:""`
}
RespondPeers is the format for the request_peers response