Documentation
¶
Index ¶
- Constants
- func DecodeMessageData(bytes []byte, v interface{}) error
- func MakeMessageBytes(messageType ProtocolMessageType, data interface{}) ([]byte, error)
- type Capability
- type CapabilityType
- type Handshake
- type Message
- type NewPeak
- type NodeType
- type Plot
- type ProtocolMessageType
- type RequestBlock
- type RequestPeers
- type RespondBlock
- type RespondPeers
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 chik 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 NewPeak ¶ added in v0.8.0
type NewPeak struct {
HeaderHash types.Bytes32 `streamable:""`
Height uint32 `streamable:""`
Weight types.Uint128 `streamable:""`
ForkPointWithPreviousPeak uint32 `streamable:""`
UnfinishedRewardBlockHash types.Bytes32 `streamable:""`
}
NewPeak is the format for the new_peak response
type NodeType ¶
type NodeType uint8
NodeType is the type of peer (farmer, full node, etc) Source for node types is chik/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 ¶
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/Chik-Network/chik-blockchain/blob/main/chik/protocols/harvester_protocol.py#L78
type ProtocolMessageType ¶
type ProtocolMessageType uint8
ProtocolMessageType corresponds to ProtocolMessageTypes in Chik
const ( // ProtocolMessageTypeHandshake Handshake ProtocolMessageTypeHandshake ProtocolMessageType = 1 // ProtocolMessageTypeNewPeak new_peak ProtocolMessageTypeNewPeak ProtocolMessageType = 20 // ProtocolMessageTypeRequestBlock request_block ProtocolMessageTypeRequestBlock ProtocolMessageType = 26 // ProtocolMessageTypeRespondBlock respond_block ProtocolMessageTypeRespondBlock ProtocolMessageType = 27 // ProtocolMessageTypeRequestPeers request_peers ProtocolMessageTypeRequestPeers ProtocolMessageType = 43 // ProtocolMessageTypeRespondPeers respond_peers ProtocolMessageTypeRespondPeers ProtocolMessageType = 44 )
type RequestBlock ¶ added in v0.8.0
type RequestBlock struct {
Height uint32 `streamable:""`
IncludeTransactionBlock bool `streamable:""`
}
RequestBlock is the format for the request_block request
type RespondBlock ¶ added in v0.8.0
RespondBlock is the format for the respond_block response
type RespondPeers ¶
type RespondPeers struct {
PeerList []types.TimestampedPeerInfo `streamable:""`
}
RespondPeers is the format for the request_peers response