clienttypes

package
v0.0.0-...-f5f0bdb Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthoritiesChange ...
	AuthoritiesChange digestEnum = iota
	// ChangesTrieRoot ...
	ChangesTrieRoot
	// Other ...
	Other
	// Seal ...
	Seal
)
View Source
const (
	// Ascending ...
	Ascending directionEnum = iota
	// Descending ...
	Descending
)
View Source
const (
	// None ...
	None statusMessageRolesEnum = 0
	// Full ...
	Full statusMessageRolesEnum = 1
	// Light ...
	Light statusMessageRolesEnum = 2
	// Authority ...
	Authority statusMessageRolesEnum = 4
)

Variables

View Source
var ErrUnknownDigest = errors.New("digest: unknown")

ErrUnknownDigest ...

View Source
var ErrUnknownDirection = errors.New("direction: unknown")

ErrUnknownDirection ...

View Source
var ErrUnknownStatusMessageRole = errors.New("status message role: unknown")

ErrUnknownStatusMessageRole ...

Functions

This section is empty.

Types

type AccountID

type AccountID [32]uint8

AccountID ...

func (*AccountID) Encode

func (a *AccountID) Encode() (string, error)

Encode ...

type AuthoritiesChangeObj

type AuthoritiesChangeObj []*AuthorityID

AuthoritiesChangeObj ... note: obj suffix is required so as to not interfere with the enum

type AuthorityID

type AuthorityID AccountID

AuthorityID ...

type BFT

type BFT struct {
	Message map[string]interface{}
}

BFT ...

func (*BFT) Decode

func (b *BFT) Decode(data []byte) error

Decode deserializes a bytes array into a message TODO: fix...

func (*BFT) Encode

func (b *BFT) Encode() ([]byte, error)

Encode serializes the message into a bytes array TODO: fix...

func (*BFT) GetHeader

func (b *BFT) GetHeader() *Header

GetHeader ...

func (*BFT) Kind

func (b *BFT) Kind() handlertypes.FuncEnum

Kind ...

func (*BFT) MarshalJSON

func (b *BFT) MarshalJSON() ([]byte, error)

MarshalJSON returns json

func (*BFT) UnmarshalJSON

func (b *BFT) UnmarshalJSON(data []byte) error

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) GetHeader

func (b *BlockAnnounce) GetHeader() *Header

GetHeader ...

func (*BlockAnnounce) Kind

Kind ...

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

func NewBlockData

func NewBlockData(input interface{}) *BlockData

NewBlockData ...

func (*BlockData) ToU8a

func (b *BlockData) ToU8a() []uint8

ToU8a ...

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) GetHeader

func (b *BlockRequest) GetHeader() *Header

GetHeader ...

func (*BlockRequest) Kind

Kind ...

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

type BlockRequestMessageFrom struct {
	Hash        []byte
	BlockNumber *big.Int
}

BlockRequestMessageFrom ...

type BlockRequestMessageTo

type BlockRequestMessageTo struct {
	Hash        []byte
	BlockNumber *big.Int
}

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) GetHeader

func (b *BlockResponse) GetHeader() *Header

GetHeader ...

func (*BlockResponse) Kind

Kind ...

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

type ChangesTrieRootObj pcrypto.Hash

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 DevConfig

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

DevConfig ...

type Digest

type Digest struct {
	Logs map[DigestEnum]interface{}
}

Digest ...

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 struct {
	BlockNumber    *big.Int
	ParentHash     []byte
	Number         *big.Int
	StateRoot      []byte
	ExtrinsicsRoot []byte
	Digest         *Digest
	Author         *AccountID
}

Header ...

func NewHeader

func NewHeader(h *Header, sessionValidators []*AccountID) (*Header, error)

NewHeader ...

func (*Header) GetBlockNumber

func (h *Header) GetBlockNumber() *big.Int

GetBlockNumber ...

func (*Header) Hash

func (h *Header) Hash() []byte

Hash ...

func (*Header) SetExtrinsicsRoot

func (h *Header) SetExtrinsicsRoot(root []byte)

SetExtrinsicsRoot ...

func (*Header) SetParentHash

func (h *Header) SetParentHash(hash []byte)

SetParentHash ...

func (*Header) SetStateRoot

func (h *Header) SetStateRoot(stateRoot []byte)

SetStateRoot ...

func (*Header) ToU8a

func (h *Header) ToU8a() []uint8

ToU8a ...

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

func DecodeMessage

func DecodeMessage(data []byte) (InterfaceMessage, error)

DecodeMessage ...

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 InterfaceRPC

type InterfaceRPC interface{}

InterfaceRPC ...

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 InterfaceTelemetry

type InterfaceTelemetry interface{}

InterfaceTelemetry ...

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 Nodes

type Nodes []string

Nodes is a list of p2p nodes

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 QueuedPeer

type QueuedPeer struct {
	Peer     InterfacePeer
	NextDial time.Time
}

QueuedPeer ...

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 Requests

type Requests []*StateRequest

Requests ...

type RolesConfig

type RolesConfig struct{}

RolesConfig ...

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 StateBlockQueue

type StateBlockQueue map[string]*StateBlock

StateBlockQueue ...

type StateBlockRequests

type StateBlockRequests map[string]*StateRequest

StateBlockRequests ...

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) Decode

func (s *Status) Decode(data []byte) error

Decode deserializes a bytes array into a message TODO: fix...

func (*Status) Encode

func (s *Status) Encode() ([]byte, error)

Encode serializes the message into a bytes array TODO: fix...

func (*Status) GetHeader

func (s *Status) GetHeader() *Header

GetHeader ...

func (*Status) Kind

func (s *Status) Kind() handlertypes.FuncEnum

Kind ...

func (*Status) MarshalJSON

func (s *Status) MarshalJSON() ([]byte, error)

MarshalJSON returns json

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(data []byte) error

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 TelemetryConfig

type TelemetryConfig struct {
	Name string
	URL  string
}

TelemetryConfig ...

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) GetHeader

func (t *Transactions) GetHeader() *Header

GetHeader ...

func (*Transactions) Kind

Kind ...

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 ...

type WasmConfig

type WasmConfig struct{}

WasmConfig ...

Directories

Path Synopsis
Package mock_clienttypes is a generated GoMock package.
Package mock_clienttypes is a generated GoMock package.

Jump to

Keyboard shortcuts

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