node

package
v0.0.0-...-cd93eb8 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2017 Delos Development Foundation and contributors. Licensed under the Apache License, Version 2.0. See the COPYING file at the root of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

Copyright 2017 Delos Development Foundation and contributors. Licensed under the Apache License, Version 2.0. See the COPYING file at the root of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

Copyright 2017 Delos Development Foundation and contributors. Licensed under the Apache License, Version 2.0. See the COPYING file at the root of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

Copyright 2017 Delos Development Foundation and contributors. Licensed under the Apache License, Version 2.0. See the COPYING file at the root of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

Index

Constants

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

Variables

View Source
var (
	ErrUnknownTx   = fmt.Errorf("unknown tx")
	ErrShardExists = fmt.Errorf("shard exists")
	ErrFailToStop  = fmt.Errorf("stop shard failed")
)
View Source
var (
	ErrInvalidChainID = fmt.Errorf("no such chain id")
)

Functions

func AppExists

func AppExists(name string) (yes bool)

func RunNode

func RunNode(logger *zap.Logger, config cfg.Config)

Types

type Accounts

type Accounts struct {
	Address string
}

type GetAccountAmountRes

type GetAccountAmountRes struct {
	Amount int `json:"amount"`
}

type LastBlockInfo

type LastBlockInfo struct {
	Height uint64
	Txs    [][]byte
	Hash   []byte
}

type ManagedState

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

type MyApp

type MyApp struct {
	Txs             [][]byte
	RunningChainIDs map[string]string
	Shards          map[string]*MyNode
	// contains filtered or unexported fields
}

func NewMyApp

func NewMyApp(logger *zap.Logger, conf config.Config) *MyApp

func (*MyApp) CheckTx

func (app *MyApp) CheckTx(bs []byte) error

func (*MyApp) CompatibleWithDngine

func (app *MyApp) CompatibleWithDngine()

func (*MyApp) ExecuteTx

func (app *MyApp) ExecuteTx(blockHash []byte, bs []byte, txIndex int) (validtx []byte, err error)

ExecuteTx execute tx one by one in the loop, without lock, so should always be called between Lock() and Unlock() on the *stateDup

func (*MyApp) GetDngineHooks

func (app *MyApp) GetDngineHooks() types.Hooks

func (*MyApp) Info

func (app *MyApp) Info() (resInfo types.ResultInfo)

func (*MyApp) LoadLastBlock

func (app *MyApp) LoadLastBlock() (lastBlock LastBlockInfo)

func (*MyApp) Lock

func (app *MyApp) Lock()

func (*MyApp) OnCommit

func (app *MyApp) OnCommit(height, round int, block *types.Block) (interface{}, error)

OnCommit run in a sync way, we don't need to lock stateDupMtx, but stateMtx is still needed

func (*MyApp) OnExecute

func (app *MyApp) OnExecute(height, round int, block *types.Block) (interface{}, error)

OnExecute would not care about Block.ExTxs

func (*MyApp) Query

func (app *MyApp) Query(query []byte) types.Result

func (*MyApp) SaveLastBlock

func (app *MyApp) SaveLastBlock(lastBlock LastBlockInfo)

func (*MyApp) Start

func (app *MyApp) Start()

Start will restore all shards according to tx history

func (*MyApp) Stop

func (app *MyApp) Stop()

Stop stops all still running shards

func (*MyApp) Unlock

func (app *MyApp) Unlock()

type MyNode

type MyNode struct {
	Dngine      *dngine.Dngine
	DngineTune  *dngine.DngineTunes
	Application types.Application
	GenesisDoc  *types.GenesisDoc
	// contains filtered or unexported fields
}

func NewMyNode

func NewMyNode(logger *zap.Logger, appName string, conf config.Config) *MyNode

func (*MyNode) GetSpecialVote

func (s *MyNode) GetSpecialVote(data []byte, validator *types.Validator) ([]byte, error)

func (*MyNode) IsRunning

func (s *MyNode) IsRunning() bool

func (*MyNode) Start

func (s *MyNode) Start() error

func (*MyNode) Stop

func (s *MyNode) Stop() bool

type MyTx

type MyTx struct {
	App           string                  `json:"app"`
	Act           byte                    `json:"act"`
	ChainID       string                  `json:"chainid"`
	Genesis       types.GenesisDoc        `json:"genesis"`
	Config        map[string]interface{}  `json:"config"`
	Time          time.Time               `json:"time"`
	Signature     crypto.SignatureEd25519 `json:"signature"`
	DestAddress   string                  `json:"destaddress"`
	SourceAddress string                  `json:"sourceaddress"`
	Amount        int                     `json:"amount"`
}

func (*MyTx) SignByPrivKey

func (t *MyTx) SignByPrivKey(p crypto.PrivKeyEd25519) error

func (*MyTx) VerifySignature

func (t *MyTx) VerifySignature(pubKey crypto.PubKeyEd25519, signature crypto.SignatureEd25519) bool

type Node

type Node struct {
	MainChainID string
	MainShard   *MyNode
	// contains filtered or unexported fields
}

func NewNode

func NewNode(logger *zap.Logger, config cfg.Config) *Node

func (*Node) NodeInfo

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

func (*Node) PrivValidator

func (n *Node) PrivValidator() *types.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 RPCNode

type RPCNode interface {
	GetShard(string) (*MyNode, error)
	Height() int
	GetBlock(height int) (*types.Block, *types.BlockMeta)
	BroadcastTx(tx []byte) error
	BroadcastTxCommit(tx []byte) error
	FlushMempool()
	GetValidators() (int, []*types.Validator)
	GetP2PNetInfo() (bool, []string, []*types.Peer)
	GetNumPeers() int
	GetConsensusStateInfo() (string, []string)
	GetNumUnconfirmedTxs() int
	GetUnconfirmedTxs() []types.Tx
	IsNodeValidator(pub crypto.PubKey) bool
	GetBlacklist() []string
	GetAccountAmount(address string) *big.Int
}

RPCNode define the node's abilities provided for rpc calls

Jump to

Keyboard shortcuts

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