node

package
v0.0.0-...-a4757fd Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const ChainIDArg = "chainid"
View Source
const (
	ReceiptsPrefix = "receipts-"
)

Variables

View Source
var (
	ErrInvalidChainID = errors.New("no such chain id")
	ErrMissingParams  = errors.New("missing params")
)
View Source
var Apps = make(map[string]AppMaker)

Functions

func AppExists

func AppExists(name string) (yes bool)

func RunNode

func RunNode(logger *zap.Logger, config *viper.Viper)

Types

type AppAttributes

type AppAttributes = map[string]string

AppAttributes is just a type alias

type AppMaker

type AppMaker func(*zap.Logger, *viper.Viper, crypto.PrivKey) (Application, error)

AppMaker is the signature for functions which take charge of create new instance of applications

type Application

type Application interface {
	agtypes.Application
	SetCore(Core)
	GetAttributes() AppAttributes
}

Application embeds types.Application, defines application interface in ann

type Broadcaster

type Broadcaster interface {
	BroadcastTx([]byte) error
}

Broadcaster means we can deliver tx in application

type Core

type Core interface {
	IsValidator() bool
	GetPublicKey() (crypto.PubKeyEd25519, bool)
	GetPrivateKey() (crypto.PrivKeyEd25519, bool)
	GetChainID() string
	GetEngine() Engine
	BroadcastTxSuperior([]byte) error
}

Core defines the interface at which an application sees its containing organization

type Engine

type Engine interface {
	GetBlock(def.INT) (*agtypes.BlockCache, *pbtypes.BlockMeta, error)
	GetBlockMeta(def.INT) (*pbtypes.BlockMeta, error)
	GetValidators() (def.INT, *agtypes.ValidatorSet)
	PrivValidator() *agtypes.PrivValidator
	BroadcastTx([]byte) error
	Query(byte, []byte) (interface{}, error)
}

Engine defines the consensus engine

type Hashable

type Hashable interface {
	Serializable
}

Hashable aliases Serializable

type IMetropolisApp

type IMetropolisApp interface {
	GetAttribute(string) (string, bool)
	GetAttributes() AppAttributes
	SetAttributes(AppAttributes)
	PushAttribute(string, string)
	AttributeExists(string) bool
}

type Node

type Node struct {
	Superior    Superior
	Angine      *angine.Angine
	Application agtypes.Application
	GenesisDoc  *agtypes.GenesisDoc
	// contains filtered or unexported fields
}

func NewNode

func NewNode(logger *zap.Logger, c *viper.Viper) *Node

func (*Node) GetConf

func (n *Node) GetConf() *viper.Viper

func (*Node) NodeInfo

func (n *Node) NodeInfo() *p2p.NodeInfo

func (*Node) PrivValidator

func (n *Node) PrivValidator() *agtypes.PrivValidator

func (*Node) Start

func (n *Node) Start() error

Call Start() after adding the listeners.

func (*Node) StartRPC

func (n *Node) StartRPC() ([]net.Listener, error)

func (*Node) Stop

func (n *Node) Stop()

type Payload

type Payload struct {
	Function string        `json:"function"`
	Params   []interface{} `json:"params"`
}

type RPCNode

type RPCNode interface {
	Height() def.INT
	GetBlock(height def.INT) (*agtypes.BlockCache, *pbtypes.BlockMeta)
	BroadcastTx(tx []byte) error
	BroadcastTxCommit(tx []byte) error
	FlushMempool()
	GetValidators() (def.INT, []*agtypes.Validator)
	GetP2PNetInfo() (bool, []string, []*agtypes.Peer)
	GetNumPeers() int
	GetConsensusStateInfo() (string, []string)
	GetNumUnconfirmedTxs() int
	GetUnconfirmedTxs() []agtypes.Tx
	IsNodeValidator(pub crypto.PubKey) bool
	GetBlacklist() []string
}

RPCNode define the node's abilities provided for rpc calls

type Serializable

type Serializable interface {
	ToBytes() ([]byte, error)
}

Serializable transforms to bytes

type Superior

type Superior interface {
	Broadcaster
}

Superior defines the application on the upper level, e.g. Metropolis

type Unserializable

type Unserializable interface {
	FromBytes(bs []byte)
}

Unserializable transforms from bytes

Jump to

Keyboard shortcuts

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