Documentation ¶
Index ¶
- Constants
- Variables
- type AccountID
- type AuthoritiesChangeObj
- type AuthorityID
- type BFT
- type BlockAnnounce
- func (b *BlockAnnounce) Decode(data []byte) error
- func (b *BlockAnnounce) Encode() ([]byte, error)
- func (b *BlockAnnounce) GetHeader() *Header
- func (b *BlockAnnounce) Kind() handlertypes.FuncEnum
- func (b *BlockAnnounce) MarshalJSON() ([]byte, error)
- func (b *BlockAnnounce) UnmarshalJSON(data []byte) error
- type BlockData
- type BlockRequest
- func (b *BlockRequest) Decode(data []byte) error
- func (b *BlockRequest) Encode() ([]byte, error)
- func (b *BlockRequest) GetHeader() *Header
- func (b *BlockRequest) Kind() handlertypes.FuncEnum
- func (b *BlockRequest) MarshalJSON() ([]byte, error)
- func (b *BlockRequest) UnmarshalJSON(data []byte) error
- type BlockRequestFields
- type BlockRequestMessage
- type BlockRequestMessageFrom
- type BlockRequestMessageTo
- type BlockResponse
- func (b *BlockResponse) Decode(data []byte) error
- func (b *BlockResponse) Encode() ([]byte, error)
- func (b *BlockResponse) GetHeader() *Header
- func (b *BlockResponse) Kind() handlertypes.FuncEnum
- func (b *BlockResponse) MarshalJSON() ([]byte, error)
- func (b *BlockResponse) UnmarshalJSON(data []byte) error
- type BlockResponseMessage
- type ChangesTrieRootObj
- type ConfigClient
- type ConfigP2P
- type ConfigPeer
- type ConfigPeers
- type ConfigRPC
- type DevConfig
- type Digest
- type DigestEnum
- type DirectionEnum
- type EventCallback
- type Header
- type InterfaceChains
- type InterfaceMessage
- type InterfaceP2P
- type InterfacePeer
- type InterfacePeers
- type InterfaceRPC
- type InterfaceSync
- type InterfaceTelemetry
- type KnownPeer
- type Node
- type Nodes
- type OnMessage
- type OtherObj
- type PeerEventCallback
- type PeersEventCallback
- type QueuedPeer
- type RawMessage
- type Requests
- type RolesConfig
- type SealObj
- type State
- type StateBlock
- type StateBlockQueue
- type StateBlockRequests
- type StateRequest
- type Status
- type StatusMessage
- type StatusMessageRolesEnum
- type SyncState
- type TelemetryConfig
- type Transactions
- func (t *Transactions) Decode(data []byte) error
- func (t *Transactions) Encode() ([]byte, error)
- func (t *Transactions) GetHeader() *Header
- func (t *Transactions) Kind() handlertypes.FuncEnum
- func (t *Transactions) MarshalJSON() ([]byte, error)
- func (t *Transactions) UnmarshalJSON(data []byte) error
- type TransactionsMessage
- type WasmConfig
Constants ¶
const ( // AuthoritiesChange ... AuthoritiesChange digestEnum = iota // ChangesTrieRoot ... ChangesTrieRoot // Other ... Other // Seal ... Seal )
const ( // Ascending ... Ascending directionEnum = iota // Descending ... Descending )
const ( // None ... None statusMessageRolesEnum = 0 // Full ... Full statusMessageRolesEnum = 1 // Light ... Light statusMessageRolesEnum = 2 // Authority ... Authority statusMessageRolesEnum = 4 )
Variables ¶
var ErrUnknownDigest = errors.New("digest: unknown")
ErrUnknownDigest ...
var ErrUnknownDirection = errors.New("direction: unknown")
ErrUnknownDirection ...
var ErrUnknownStatusMessageRole = errors.New("status message role: unknown")
ErrUnknownStatusMessageRole ...
Functions ¶
This section is empty.
Types ¶
type AuthoritiesChangeObj ¶
type AuthoritiesChangeObj []*AuthorityID
AuthoritiesChangeObj ... note: obj suffix is required so as to not interfere with the enum
type BFT ¶
type BFT struct {
Message map[string]interface{}
}
BFT ...
func (*BFT) UnmarshalJSON ¶
UnmarshalJSON converts json to a message
type BlockAnnounce ¶
type BlockAnnounce struct {
Header *Header
}
BlockAnnounce ...
func (*BlockAnnounce) Decode ¶
func (b *BlockAnnounce) Decode(data []byte) error
Decode deserializes a bytes array into a message TODO: fix
func (*BlockAnnounce) Encode ¶
func (b *BlockAnnounce) Encode() ([]byte, error)
Encode serializes the message into a bytes array TODO: fix
func (*BlockAnnounce) MarshalJSON ¶
func (b *BlockAnnounce) MarshalJSON() ([]byte, error)
MarshalJSON returns json
func (*BlockAnnounce) UnmarshalJSON ¶
func (b *BlockAnnounce) UnmarshalJSON(data []byte) error
UnmarshalJSON converts json to a message
type BlockData ¶
type BlockData struct { Hash []byte Header *Header Body []byte Receipt []byte MessageQueue []byte Justification []byte }
BlockData TODO TODO: https://github.com/polkadot-js/client/blob/master/packages/client-types/src/BlockData.ts
type BlockRequest ¶
type BlockRequest struct {
Message *BlockRequestMessage
}
BlockRequest ... note: required by sync.provideBlocks see: https://github.com/polkadot-js/client/blob/master/packages/client-types/src/messages/BlockRequest.ts
func (*BlockRequest) Decode ¶
func (b *BlockRequest) Decode(data []byte) error
Decode deserializes a bytes array into a message
func (*BlockRequest) Encode ¶
func (b *BlockRequest) Encode() ([]byte, error)
Encode serializes the message into a bytes array
func (*BlockRequest) MarshalJSON ¶
func (b *BlockRequest) MarshalJSON() ([]byte, error)
MarshalJSON returns json
func (*BlockRequest) UnmarshalJSON ¶
func (b *BlockRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON converts json to a message
type BlockRequestFields ¶
type BlockRequestFields struct { Header int Body int Receipt int MessageQueue int Justification int }
BlockRequestFields .. TODO: use enum? https://github.com/polkadot-js/client/blob/master/packages/client-types/src/messages/BlockRequest.ts#L13
type BlockRequestMessage ¶
type BlockRequestMessage struct { ID uint64 Fields *BlockRequestFields From *BlockRequestMessageFrom To *BlockRequestMessageTo Max *uint64 Direction DirectionEnum // note: create enums? }
BlockRequestMessage ...
type BlockRequestMessageFrom ¶
BlockRequestMessageFrom ...
type BlockRequestMessageTo ¶
BlockRequestMessageTo ...
type BlockResponse ¶
type BlockResponse struct {
Message *BlockResponseMessage
}
BlockResponse ... note: required by sync.provideBlocks see: https://github.com/polkadot-js/client/blob/master/packages/client-types/src/messages/BlockResponse.ts
func (*BlockResponse) Decode ¶
func (b *BlockResponse) Decode(data []byte) error
Decode deserializes a bytes array into a message TODO: fix...
func (*BlockResponse) Encode ¶
func (b *BlockResponse) Encode() ([]byte, error)
Encode serializes the message into a bytes array TODO: fix...
func (*BlockResponse) MarshalJSON ¶
func (b *BlockResponse) MarshalJSON() ([]byte, error)
MarshalJSON returns json
func (*BlockResponse) UnmarshalJSON ¶
func (b *BlockResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON converts json to a message
type BlockResponseMessage ¶
type BlockResponseMessage struct { Blocks []*StateBlock // TODO: big.Int? ID uint64 }
BlockResponseMessage ...
type ChangesTrieRootObj ¶
ChangesTrieRootObj ... note: obj suffix is required so as to not interfere with the enum
type ConfigClient ¶
type ConfigClient struct { // TODO: types Chain string DB *clientdbtypes.Config Dev *DevConfig P2P *ConfigP2P RPC *ConfigRPC Peer *ConfigPeer Peers *ConfigPeers Roles []StatusMessageRolesEnum Telemetry *TelemetryConfig Wasm *WasmConfig }
ConfigClient ...
type ConfigP2P ¶
type ConfigP2P struct { // Address is the address of the new node Address string // ClientID is the id of the node ClientID string // MaxPeers is the maximum number of connected peers to accept MaxPeers uint // Nodes are the boot nodes Nodes Nodes // NoBootNodes defines whether the node should connect to others on boot // TODO: re-write this NoBootNodes bool // Port is the port of the new node Port uint // Syncer is used to sync the node Syncer InterfaceSync // Priv .. Priv ic.PrivKey // Pub ... Pub ic.PubKey // Context ... Context context.Context }
ConfigP2P is used to configure a new node
type ConfigPeer ¶
type ConfigPeer struct { // BestHash TODO BestHash []byte // BestNumber TODO BestNumber *big.Int // ID is the peer id ID libpeer.ID // PeerInfo is the peer metadata PeerInfo *pstore.PeerInfo // ShortID TODO ShortID string }
ConfigPeer is passed to New to create a new peer
type ConfigPeers ¶
type ConfigPeers struct { // Priv .. Priv ic.PrivKey // Pub ... Pub ic.PubKey // ID ... ID libpeer.ID }
ConfigPeers ...
type ConfigRPC ¶
type ConfigRPC struct { Host libp2pHost.Host SystemService system.ServiceInterface StateService state.ServiceInterface // TODO: What's the diff between rpc chain and p2p chain? ChainService chain.ServiceInterface AuthorService author.ServiceInterface ID *protocol.ID }
ConfigRPC is passed to NewServer
type DigestEnum ¶
type DigestEnum interface { Type() digestEnum String() string }
DigestEnum ...
func AllDigestEnums ¶
func AllDigestEnums() []DigestEnum
AllDigestEnums returns all of the digest enums
func DigestEnumFromString ¶
func DigestEnumFromString(s string) (DigestEnum, error)
DigestEnumFromString ...
type DirectionEnum ¶
type DirectionEnum interface { Type() directionEnum String() string }
DirectionEnum ...
func AllDirectionEnums ¶
func AllDirectionEnums() []DirectionEnum
AllDirectionEnums returns all of the direction enums
func DirectionEnumFromString ¶
func DirectionEnumFromString(s string) (DirectionEnum, error)
DirectionEnumFromString ...
type EventCallback ¶
type EventCallback func() (interface{}, error)
EventCallback is called after an event has been received
type Header ¶
type Header struct { BlockNumber *big.Int ParentHash []byte Number *big.Int StateRoot []byte ExtrinsicsRoot []byte Digest *Digest Author *AccountID }
Header ...
func (*Header) SetExtrinsicsRoot ¶
SetExtrinsicsRoot ...
type InterfaceChains ¶
type InterfaceChains interface { // note: required from p2p.peer.AddConnection GetBestBlocksNumber() (*big.Int, error) GetBestBlocksHash() ([]byte, error) GetGenesisHash() ([]byte, error) // note: required by sync.processBlock ImportBlock(block *StateBlock) (bool, error) // note required by sync.QueuBlocks GetBlockDataByHash(hash []byte) (*StateBlock, error) }
InterfaceChains describes the methods of the chains service
type InterfaceMessage ¶
type InterfaceMessage interface { // Kind returns the message's kind Kind() handlertypes.FuncEnum // Encode serializes the message into a bytes array Encode() ([]byte, error) // Decode deserializes a bytes array into a message Decode(bytes []byte) error // Marshal returns json MarshalJSON() ([]byte, error) // Unmarshal converts json to a message UnmarshalJSON(bytes []byte) error // GetHeader ... GetHeader() *Header }
InterfaceMessage defines the methods of Message
type InterfaceP2P ¶
type InterfaceP2P interface { // IsStarted returns true if the p2p interface has started IsStarted() bool // GetNumPeers returns the number of connected peers GetNumPeers() (uint, error) // On handles messages On(event p2ptypes.EventEnum, cb EventCallback) // Start starts the p2p service Start() error // Stop stops the p2p service Stop() error // Config returns the config Config() ConfigClient // GetSyncer ... GetSyncer() (InterfaceSync, error) }
InterfaceP2P defines the methods of the p2p service
type InterfacePeer ¶
type InterfacePeer interface { // AddConnection is used to add a connection AddConnection(conn inet.Conn, isWritable bool) (uint, error) // Disconnect disconnects from the peer Disconnect() error // IsActive returns whether the peer is active or not IsActive() (bool, error) // IsWritable returns whether the peer is writable or not IsWritable() (bool, error) // On defines the event handlers On(event peertypes.EventEnum, cb PeerEventCallback) // Send is used to send the peer a message Send(msg InterfaceMessage) (bool, error) // SetBest sets a new block SetBest(blockNumber *big.Int, hash []byte) error // Config returns the peer config Config() ConfigClient // GetChain ... GetChain() (InterfaceChains, error) // GetID ... GetID() string // GetNextID ... GetNextID() uint // GetPeerInfo ... GetPeerInfo() pstore.PeerInfo // GetShortID ... GetShortID() string // Receive ... Receive(stream inet.Stream) error // GetBestNumber ... GetBestNumber() *big.Int }
InterfacePeer defines the methods of peer
type InterfacePeers ¶
type InterfacePeers interface { // Add adds a peer to peers Add(pi pstore.PeerInfo) (*KnownPeer, error) // CountAll returns the number of known peers CountAll() (uint, error) // Count returns the number of connected peers Count() (uint, error) // Get returns a peer Get(pi pstore.PeerInfo) (*KnownPeer, error) // GetFromID returns a peer GetFromID(id libpeer.ID) (*KnownPeer, error) // Log TODO Log(event peerstypes.EventEnum, iface interface{}) error // On handles peers events On(event peerstypes.EventEnum, cb PeersEventCallback) // KnownPeers returns the peers KnownPeers() ([]*KnownPeer, error) }
InterfacePeers defines the methods of the peers
type InterfaceSync ¶
type InterfaceSync interface { // On handles events On(event synctypes.EventEnum, cb EventCallback) // QueueBlocks ... // TODO ... QueueBlocks(pr InterfacePeer, response *BlockResponse) error // RequestBlocks ... // TODO ... RequestBlocks(pr InterfacePeer) error // ProvideBlocks ... ProvideBlocks(pr InterfacePeer, request *BlockRequest) error // PeerRequests ... PeerRequests(pr InterfacePeer) (Requests, error) }
InterfaceSync defines the methods of the sync service
type KnownPeer ¶
type KnownPeer struct { // Peer is the known peer Peer InterfacePeer // IsConnected is true if the peer is connected IsConnected bool }
KnownPeer is a peer that has been discovered
type Node ¶
type Node struct { // Address is the address of the node Address string // Port is the port on which the node is communicating Port uint }
Node contains information about a peer node
type OnMessage ¶
type OnMessage struct { Peer InterfacePeer Message InterfaceMessage }
OnMessage ...
type OtherObj ¶
type OtherObj []byte
OtherObj ... note: obj suffix is required so as to not interfere with the enum
type PeerEventCallback ¶
type PeerEventCallback func(iface interface{}) (interface{}, error)
PeerEventCallback is a function that is called on a peer event
type PeersEventCallback ¶
type PeersEventCallback func(iface interface{}) (interface{}, error)
PeersEventCallback ...
type RawMessage ¶
type RawMessage struct { // Message is a json object Message map[string]interface{} // Type defines the message type Type uint }
RawMessage is a message struct that is sent between nodes
type SealObj ¶
type SealObj struct {
Slot int
}
SealObj ... note: obj suffix is required so as to not interfere with the enum
type State ¶
type State struct { // Chain TODO Chain InterfaceChains // Config is the current configuration of the node Config *ConfigClient // Host is the libp2p host Host libp2pHost.Host // Peers are the connected peers Peers InterfacePeers // Sync is the current sync state SyncState *SyncState }
State is the current node state
type StateBlock ¶
type StateBlock struct { // Block ... Block *BlockData // Peer ... Peer InterfacePeer }
StateBlock ...
type StateRequest ¶
type StateRequest struct { // ID ... // TODO: big.Int? ID uint64 // Peer .. Peer InterfacePeer // Request ... Request *BlockRequest // Timeout ... Timeout int64 }
StateRequest TODO
type Status ¶
type Status struct {
Message *StatusMessage
}
Status ... TODO: this needs to implement the message interface https://github.com/polkadot-js/client/blob/master/packages/client-types/src/messages/Status.ts
func (*Status) MarshalJSON ¶
MarshalJSON returns json
func (*Status) UnmarshalJSON ¶
UnmarshalJSON converts json to a message
type StatusMessage ¶
type StatusMessage struct { Roles []StatusMessageRolesEnum BestNumber *big.Int BestHash []byte GenesisHash []byte ChainStatus []byte Version string }
StatusMessage ...
type StatusMessageRolesEnum ¶
type StatusMessageRolesEnum interface { Type() statusMessageRolesEnum String() string }
StatusMessageRolesEnum ...
func AllStatusMessageRolesEnums ¶
func AllStatusMessageRolesEnums() []StatusMessageRolesEnum
AllStatusMessageRolesEnums returns all of the roles enums
func StatusMessageRolesEnumFromString ¶
func StatusMessageRolesEnumFromString(s string) (StatusMessageRolesEnum, error)
StatusMessageRolesEnumFromString ...
type SyncState ¶
type SyncState struct { // BlockRequests ... BlockRequests StateBlockRequests // BlockQueue ... BlockQueue StateBlockQueue // Status ... Status synctypes.StatusEnum }
SyncState TODO
type Transactions ¶
type Transactions struct {
Message *TransactionsMessage
}
Transactions ...
func (*Transactions) Decode ¶
func (t *Transactions) Decode(data []byte) error
Decode deserializes a bytes array into a message TODO: fix...
func (*Transactions) Encode ¶
func (t *Transactions) Encode() ([]byte, error)
Encode serializes the message into a bytes array TODO: fix...
func (*Transactions) MarshalJSON ¶
func (t *Transactions) MarshalJSON() ([]byte, error)
MarshalJSON returns json
func (*Transactions) UnmarshalJSON ¶
func (t *Transactions) UnmarshalJSON(data []byte) error
UnmarshalJSON converts json to a message
type TransactionsMessage ¶
type TransactionsMessage struct {
Transactions []byte
}
TransactionsMessage ...