abey

package
v0.0.0-...-15e8d78 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: GPL-3.0, GPL-3.0 Imports: 66 Imported by: 0

README

abey

init

Documentation

Overview

Package abey implements the Abeychain protocol.

Index

Constants

View Source
const (
	// Protocol messages belonging to abey/63
	StatusMsg              = 0x00
	NewFastBlockHashesMsg  = 0x01
	TxMsg                  = 0x02
	GetFastBlockHeadersMsg = 0x03
	FastBlockHeadersMsg    = 0x04
	GetFastBlockBodiesMsg  = 0x05
	FastBlockBodiesMsg     = 0x06
	NewFastBlockMsg        = 0x07
	TbftNodeInfoMsg        = 0x08

	//snail sync
	NewFruitMsg             = 0x09
	GetSnailBlockHeadersMsg = 0x0a
	SnailBlockHeadersMsg    = 0x0b
	GetSnailBlockBodiesMsg  = 0x0c
	SnailBlockBodiesMsg     = 0x0d
	NewSnailBlockMsg        = 0x0e

	GetNodeDataMsg         = 0x0f
	NodeDataMsg            = 0x10
	GetReceiptsMsg         = 0x11
	ReceiptsMsg            = 0x12
	NewSnailBlockHashesMsg = 0x13

	TbftNodeInfoHashMsg = 0x15
	GetTbftNodeInfoMsg  = 0x16
)

abey protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
)
View Source
const DefaultULCMinTrustedFraction = 75
View Source
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message

Variables

View Source
var DefaultConfig = Config{
	SyncMode: downloader.FullSync,
	MinervaHash: minerva.Config{
		CacheDir:       "minerva",
		CachesInMem:    2,
		CachesOnDisk:   3,
		DatasetsInMem:  1,
		DatasetsOnDisk: 2,
	},
	NetworkId:     179,
	LightPeers:    20,
	DatabaseCache: 768,
	TrieCache:     256,
	TrieTimeout:   60 * time.Minute,
	MinerGasFloor: 16000000,
	MinerGasCeil:  20000000,
	GasPrice:      big.NewInt(10 * params.GWei),

	TxPool:    core.DefaultTxPoolConfig,
	SnailPool: snailchain.DefaultSnailPoolConfig,
	GPO: gasprice.Config{
		Blocks:     20,
		Percentile: 60,
	},
	MinerThreads: 2,
	Port:         30310,
	StandbyPort:  30311,
}

DefaultConfig contains default settings for use on the ABEY chain main net.

View Source
var ProtocolLengths = []uint64{32, 20}

ProtocolLengths are the number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "abey"

ProtocolName is the official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{abey64, abey63}

ProtocolVersions are the upported versions of the abey protocol (first is primary).

Functions

func CreateConsensusEngine

func CreateConsensusEngine(ctx *node.ServiceContext, config *ethash.Config, chainConfig *params.ChainConfig,
	db abeydb.Database) consensus.Engine

CreateConsensusEngine creates the required type of consensus engine instance for an Abeychain service

func CreateDB

func CreateDB(ctx *node.ServiceContext, config *Config, name string) (abeydb.Database, error)

CreateDB creates the chain database.

func NewBloomIndexer

func NewBloomIndexer(db abeydb.Database, size, confirms uint64, light bool) *core.ChainIndexer

NewBloomIndexer returns a chain indexer that generates bloom bits data for the canonical chain for fast logs filtering.

Types

type ABEYAPIBackend

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

ABEYAPIBackend implements ethapi.Backend for full nodes

func (*ABEYAPIBackend) AccountManager

func (b *ABEYAPIBackend) AccountManager() *accounts.Manager

AccountManager returns Account Manager

func (*ABEYAPIBackend) BlockByNumber

func (b *ABEYAPIBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)

BlockByNumber returns block of fast chain by the number

func (*ABEYAPIBackend) BloomStatus

func (b *ABEYAPIBackend) BloomStatus() (uint64, uint64)

BloomStatus returns Bloom Status

func (*ABEYAPIBackend) ChainConfig

func (b *ABEYAPIBackend) ChainConfig() *params.ChainConfig

ChainConfig returns the active chain configuration.

func (*ABEYAPIBackend) ChainDb

func (b *ABEYAPIBackend) ChainDb() abeydb.Database

ChainDb returns tht database of fastchain

func (*ABEYAPIBackend) CurrentBlock

func (b *ABEYAPIBackend) CurrentBlock() *types.Block

CurrentBlock return the fast chain current Block

func (*ABEYAPIBackend) CurrentSnailBlock

func (b *ABEYAPIBackend) CurrentSnailBlock() *types.SnailBlock

CurrentSnailBlock return the Snail chain current Block

func (*ABEYAPIBackend) Downloader

func (b *ABEYAPIBackend) Downloader() *downloader.Downloader

Downloader returns the fast downloader

func (*ABEYAPIBackend) EventMux

func (b *ABEYAPIBackend) EventMux() *event.TypeMux

EventMux returns Event locker

func (*ABEYAPIBackend) GetBalanceChangeBySnailNumber

func (b *ABEYAPIBackend) GetBalanceChangeBySnailNumber(snailNumber rpc.BlockNumber) *types.BalanceChangeContent

func (*ABEYAPIBackend) GetBlock

func (b *ABEYAPIBackend) GetBlock(ctx context.Context, hash common.Hash) (*types.Block, error)

GetBlock returns the block by the block's hash

func (*ABEYAPIBackend) GetChainRewardContent

func (b *ABEYAPIBackend) GetChainRewardContent(blockNr rpc.BlockNumber) *types.ChainReward

func (*ABEYAPIBackend) GetCommittee

func (b *ABEYAPIBackend) GetCommittee(number rpc.BlockNumber) (map[string]interface{}, error)

func (*ABEYAPIBackend) GetCurrentCommitteeNumber

func (b *ABEYAPIBackend) GetCurrentCommitteeNumber() *big.Int

func (*ABEYAPIBackend) GetEVM

func (b *ABEYAPIBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)

GetEVM returns the EVM

func (*ABEYAPIBackend) GetFruit

func (b *ABEYAPIBackend) GetFruit(ctx context.Context, fastblockHash common.Hash) (*types.SnailBlock, error)

GetFruit returns the fruit by the block's hash

func (*ABEYAPIBackend) GetLogs

func (b *ABEYAPIBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

GetLogs returns the logs by txhash

func (*ABEYAPIBackend) GetPoolNonce

func (b *ABEYAPIBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)

GetPoolNonce returns user nonce by user address in txpool

func (*ABEYAPIBackend) GetPoolTransaction

func (b *ABEYAPIBackend) GetPoolTransaction(hash common.Hash) *types.Transaction

GetPoolTransaction returns Transaction by txHash in txpool

func (*ABEYAPIBackend) GetPoolTransactions

func (b *ABEYAPIBackend) GetPoolTransactions() (types.Transactions, error)

GetPoolTransactions returns Transactions by pending state in txpool

func (*ABEYAPIBackend) GetReceipts

func (b *ABEYAPIBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)

GetReceipts returns the Receipt details by txhash

func (*ABEYAPIBackend) GetReward

func (b *ABEYAPIBackend) GetReward(number int64) *types.BlockReward

GetReward returns the Reward info by number in fastchain

func (*ABEYAPIBackend) GetSnailBlock

func (b *ABEYAPIBackend) GetSnailBlock(ctx context.Context, hash common.Hash) (*types.SnailBlock, error)

GetSnailBlock returns the snail block by the block's hash

func (*ABEYAPIBackend) GetSnailRewardContent

func (b *ABEYAPIBackend) GetSnailRewardContent(snailNumber rpc.BlockNumber) *types.SnailRewardContenet

GetSnailRewardContent returns the Reward content by number in Snailchain

func (*ABEYAPIBackend) GetStateChangeByFastNumber

func (b *ABEYAPIBackend) GetStateChangeByFastNumber(fastNumber rpc.BlockNumber) *types.BlockBalance

GetStateChangeByFastNumber returns the Committee info by committee number

func (*ABEYAPIBackend) GetTd

func (b *ABEYAPIBackend) GetTd(blockHash common.Hash) *big.Int

GetTd returns the total diffcult with block height by blockhash

func (*ABEYAPIBackend) HeaderByHash

func (b *ABEYAPIBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash returns header of fast chain by the hash

func (*ABEYAPIBackend) HeaderByNumber

func (b *ABEYAPIBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)

HeaderByNumber returns Header of fast chain by the number rpc.PendingBlockNumber == "pending"; rpc.LatestBlockNumber == "latest" ; rpc.LatestBlockNumber == "earliest"

func (*ABEYAPIBackend) ProtocolVersion

func (b *ABEYAPIBackend) ProtocolVersion() int

ProtocolVersion returns the version of protocol

func (*ABEYAPIBackend) SendTx

func (b *ABEYAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error

SendTx returns nil by success to add local txpool

func (*ABEYAPIBackend) ServiceFilter

func (b *ABEYAPIBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)

ServiceFilter make the Filter for the truechian

func (*ABEYAPIBackend) SetHead

func (b *ABEYAPIBackend) SetHead(number uint64)

SetHead Set the newest position of Fast Chain, that will reset the fast blockchain comment

func (*ABEYAPIBackend) SetSnailHead

func (b *ABEYAPIBackend) SetSnailHead(number uint64)

SetSnailHead Set the newest position of snail chain

func (*ABEYAPIBackend) SnailBlockByNumber

func (b *ABEYAPIBackend) SnailBlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.SnailBlock, error)

SnailBlockByNumber returns block of snial chain by the number

func (*ABEYAPIBackend) SnailHeaderByNumber

func (b *ABEYAPIBackend) SnailHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.SnailHeader, error)

SnailHeaderByNumber returns Header of snail chain by the number rpc.PendingBlockNumber == "pending"; rpc.LatestBlockNumber == "latest" ; rpc.LatestBlockNumber == "earliest"

func (*ABEYAPIBackend) SnailPoolContent

func (b *ABEYAPIBackend) SnailPoolContent() []*types.SnailBlock

SnailPoolContent returns snail pool content

func (*ABEYAPIBackend) SnailPoolInspect

func (b *ABEYAPIBackend) SnailPoolInspect() []*types.SnailBlock

SnailPoolInspect returns snail pool Inspect

func (*ABEYAPIBackend) SnailPoolStats

func (b *ABEYAPIBackend) SnailPoolStats() (pending int, unVerified int)

SnailPoolStats returns snail pool Stats

func (*ABEYAPIBackend) StateAndHeaderByHash

func (b *ABEYAPIBackend) StateAndHeaderByHash(ctx context.Context, hash common.Hash) (*state.StateDB, *types.Header, error)

func (*ABEYAPIBackend) StateAndHeaderByNumber

func (b *ABEYAPIBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)

StateAndHeaderByNumber returns the state of block by the number

func (*ABEYAPIBackend) StateAndHeaderByNumberOrHash

func (b *ABEYAPIBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)

func (*ABEYAPIBackend) Stats

func (b *ABEYAPIBackend) Stats() (pending int, queued int)

Stats returns the count tx in txpool

func (*ABEYAPIBackend) SubscribeChainEvent

func (b *ABEYAPIBackend) SubscribeChainEvent(ch chan<- types.FastChainEvent) event.Subscription

SubscribeChainEvent registers a subscription of chainEvnet in fast blockchain

func (*ABEYAPIBackend) SubscribeChainHeadEvent

func (b *ABEYAPIBackend) SubscribeChainHeadEvent(ch chan<- types.FastChainHeadEvent) event.Subscription

SubscribeChainHeadEvent registers a subscription of chainHeadEvnet in fast blockchain

func (*ABEYAPIBackend) SubscribeChainSideEvent

func (b *ABEYAPIBackend) SubscribeChainSideEvent(ch chan<- types.FastChainSideEvent) event.Subscription

SubscribeChainSideEvent registers a subscription of chainSideEvnet in fast blockchain,deprecated

func (*ABEYAPIBackend) SubscribeLogsEvent

func (b *ABEYAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription

SubscribeLogsEvent registers a subscription of log in fast blockchain

func (*ABEYAPIBackend) SubscribeNewTxsEvent

func (b *ABEYAPIBackend) SubscribeNewTxsEvent(ch chan<- types.NewTxsEvent) event.Subscription

SubscribeNewTxsEvent returns the subscript event of new tx

func (*ABEYAPIBackend) SubscribeRemovedLogsEvent

func (b *ABEYAPIBackend) SubscribeRemovedLogsEvent(ch chan<- types.RemovedLogsEvent) event.Subscription

SubscribeRemovedLogsEvent registers a subscription of RemovedLogsEvent in fast blockchain

func (*ABEYAPIBackend) SuggestPrice

func (b *ABEYAPIBackend) SuggestPrice(ctx context.Context) (*big.Int, error)

SuggestPrice returns tht suggest gas price

func (*ABEYAPIBackend) TxPoolContent

type Abeychain

type Abeychain struct {
	APIBackend *ABEYAPIBackend
	// contains filtered or unexported fields
}

Abeychain implements the Abeychain full node service.

func New

func New(ctx *node.ServiceContext, config *Config) (*Abeychain, error)

New creates a new Abeychain object (including the initialisation of the common Abeychain object)

func (*Abeychain) APIs

func (s *Abeychain) APIs() []rpc.API

APIs return the collection of RPC services the abey package offers. NOTE, some of these services probably need to be moved to somewhere else.

func (*Abeychain) AccountManager

func (s *Abeychain) AccountManager() *accounts.Manager

func (*Abeychain) AddLesServer

func (s *Abeychain) AddLesServer(ls LesServer)

func (*Abeychain) ArchiveMode

func (s *Abeychain) ArchiveMode() bool

func (*Abeychain) BlockChain

func (s *Abeychain) BlockChain() *core.BlockChain

func (*Abeychain) ChainDb

func (s *Abeychain) ChainDb() abeydb.Database

func (*Abeychain) Config

func (s *Abeychain) Config() *Config

func (*Abeychain) Downloader

func (s *Abeychain) Downloader() *downloader.Downloader

func (*Abeychain) Engine

func (s *Abeychain) Engine() consensus.Engine

func (*Abeychain) EthVersion

func (s *Abeychain) EthVersion() int

func (*Abeychain) Etherbase

func (s *Abeychain) Etherbase() (eb common.Address, err error)

func (*Abeychain) EventMux

func (s *Abeychain) EventMux() *event.TypeMux

func (*Abeychain) IsListening

func (s *Abeychain) IsListening() bool

func (*Abeychain) IsMining

func (s *Abeychain) IsMining() bool

func (*Abeychain) Miner

func (s *Abeychain) Miner() *miner.Miner

func (*Abeychain) NetVersion

func (s *Abeychain) NetVersion() uint64

func (*Abeychain) PbftAgent

func (s *Abeychain) PbftAgent() *PbftAgent

func (*Abeychain) Protocols

func (s *Abeychain) Protocols() []p2p.Protocol

Protocols implements node.Service, returning all the currently configured network protocols to start.

func (*Abeychain) ResetWithFastGenesisBlock

func (s *Abeychain) ResetWithFastGenesisBlock(gb *types.Block)

func (*Abeychain) ResetWithGenesisBlock

func (s *Abeychain) ResetWithGenesisBlock(gb *types.Block)

func (*Abeychain) SetEtherbase

func (s *Abeychain) SetEtherbase(etherbase common.Address)

SetEtherbase sets the mining reward address.

func (*Abeychain) SnailBlockChain

func (s *Abeychain) SnailBlockChain() *chain.SnailBlockChain

func (*Abeychain) SnailPool

func (s *Abeychain) SnailPool() *chain.SnailPool

func (*Abeychain) Start

func (s *Abeychain) Start(srvr *p2p.Server) error

Start implements node.Service, starting all internal goroutines needed by the Abeychain protocol implementation.

func (*Abeychain) StartMining

func (s *Abeychain) StartMining(local bool) error

func (*Abeychain) Stop

func (s *Abeychain) Stop() error

Stop implements node.Service, terminating all internal goroutines used by the Abeychain protocol.

func (*Abeychain) StopMining

func (s *Abeychain) StopMining()

func (*Abeychain) Synced

func (s *Abeychain) Synced() bool

func (*Abeychain) TxPool

func (s *Abeychain) TxPool() *core.TxPool

type AgentNetworkProxy

type AgentNetworkProxy interface {
	// SubscribeNewPbftSignEvent should return an event subscription of
	// PbftSignEvent and send events to the given channel.
	SubscribeNewPbftSignEvent(chan<- types.PbftSignEvent) event.Subscription
	// SubscribeNodeInfoEvent should return an event subscription of
	// NodeInfoEvent and send events to the given channel.
	SubscribeNodeInfoEvent(chan<- types.NodeInfoEvent) event.Subscription
	// AddRemoteNodeInfo should add the given NodeInfo to the pbft agent.
	AddRemoteNodeInfo(*types.EncryptNodeMessage) error
	//GetNodeInfoByHash get crypto nodeInfo  by hash
	GetNodeInfoByHash(nodeInfoHash common.Hash) (*types.EncryptNodeMessage, bool)
	//GetPrivateKey get crypto privateKey
	GetPrivateKey() *ecdsa.PrivateKey
}

type AgentWork

type AgentWork struct {
	Block *types.Block // the new block
	// contains filtered or unexported fields
}

AgentWork is the leader current environment and holds all of the current state information

type Backend

type Backend interface {
	BlockChain() *core.BlockChain
	SnailBlockChain() *snailchain.SnailBlockChain
	TxPool() *core.TxPool
	Config() *Config
	Etherbase() (etherbase common.Address, err error)
}

Backend wraps all methods required for pbft_agent

type BadBlockArgs

type BadBlockArgs struct {
	Hash  common.Hash            `json:"hash"`
	Block map[string]interface{} `json:"block"`
	RLP   string                 `json:"rlp"`
}

BadBlockArgs represents the entries in the list returned when bad blocks are queried.

type BlockBodiesRawData

type BlockBodiesRawData struct {
	Bodies []rlp.RawValue
	Call   uint32 // Distinguish fetcher and downloader
}

BlockBodiesRawData represents a block header send.

type BlockHeadersData

type BlockHeadersData struct {
	Headers      []*types.Header
	SnailHeaders []*types.SnailHeader
	Call         uint32 // Distinguish fetcher and downloader
}

BlockHeadersData represents a block header send.

type BloomIndexer

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

BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the Abeychain header bloom filters, permitting blazing fast filtering.

func (*BloomIndexer) Commit

func (b *BloomIndexer) Commit() error

Commit implements core.ChainIndexerBackend, finalizing the bloom section and writing it out into the database.

func (*BloomIndexer) Process

func (b *BloomIndexer) Process(ctx context.Context, header *types.Header) error

Process implements core.ChainIndexerBackend, adding a new header's bloom into the index.

func (*BloomIndexer) Reset

func (b *BloomIndexer) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error

Reset implements core.ChainIndexerBackend, starting a new bloombits index section.

type Config

type Config struct {
	// The genesis block, which is inserted if the database is empty.
	// If nil, the Abeychain main net block is used.
	Genesis *core.Genesis

	// Protocol options
	NetworkId    uint64 // Network ID to use for selecting peers to connect to
	SyncMode     downloader.SyncMode
	NoPruning    bool
	DeletedState bool

	// Whitelist of required block number -> hash values to accept
	Whitelist map[uint64]common.Hash `toml:"-"`

	// Light client options
	LightServ  int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
	LightPeers int `toml:",omitempty"` // Maximum number of LES client peers

	EnableElection bool `toml:",omitempty"`
	// CommitteeKey is the ECDSA private key for committee member.
	// If this filed is empty, can't be a committee member.
	CommitteeKey []byte `toml:",omitempty"`

	PrivateKey *ecdsa.PrivateKey `toml:"-"`

	// Host is the host interface on which to start the pbft server. If this
	// field is empty, can't be a committee member.
	Host string `toml:",omitempty"`

	// Port is the TCP port number on which to start the pbft server.
	Port int `toml:",omitempty"`

	// StandByPort is the TCP port number on which to start the pbft server.
	StandbyPort int `toml:",omitempty"`

	// Ultra Light client options
	ULC *ULCConfig `toml:",omitempty"`

	// Database options
	SkipBcVersionCheck bool `toml:"-"`
	DatabaseHandles    int  `toml:"-"`
	DatabaseCache      int
	TrieCache          int
	TrieTimeout        time.Duration

	// Mining-related options
	Etherbase     common.Address `toml:",omitempty"`
	MinerThreads  int            `toml:",omitempty"`
	ExtraData     []byte         `toml:",omitempty"`
	MinerGasFloor uint64
	MinerGasCeil  uint64
	GasPrice      *big.Int

	// MinervaHash options
	MinervaHash minerva.Config

	// Transaction pool options
	TxPool core.TxPoolConfig

	//fruit pool options
	SnailPool snailchain.SnailPoolConfig

	// Gas Price Oracle options
	GPO gasprice.Config

	// Enables tracking of SHA3 preimages in the VM
	EnablePreimageRecording bool

	// Miscellaneous options
	DocRoot string `toml:"-"`

	// true indicate singlenode start
	NodeType bool `toml:",omitempty"`

	//true indicate only mine fruit
	MineFruit bool `toml:",omitempty"`

	//true indicate  mine snailblock and fruit
	Mine bool `toml:",omitempty"`

	//true indicate only remote mine
	RemoteMine bool `toml:",omitempty"`
}

func (*Config) GetNodeType

func (c *Config) GetNodeType() bool

func (Config) MarshalTOML

func (c Config) MarshalTOML() (interface{}, error)

func (*Config) UnmarshalTOML

func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error

type LesServer

type LesServer interface {
	Start(srvr *p2p.Server)
	Stop()
	Protocols() []p2p.Protocol
	SetBloomBitsIndexer(bbIndexer *core.ChainIndexer)
}

type NodeInfo

type NodeInfo struct {
	Network      uint64              `json:"network"`      // Abeychain network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
	Genesis      common.Hash         `json:"genesis"`      // SHA3 hash of the host's genesis block
	Config       *params.ChainConfig `json:"config"`       // Chain configuration for the fork rules
	Head         common.Hash         `json:"head"`         // SHA3 hash of the host's best owned block
	Difficulty   *big.Int            `json:"snailTd"`      // Total difficulty of the host's blockchain
	SnailGenesis common.Hash         `json:"snailGenesis"` // SHA3 hash of the host's genesis block
	SnailConfig  *params.ChainConfig `json:"snailConfig"`  // Chain configuration for the fork rules
	SnailHead    common.Hash         `json:"snailHead"`    // SHA3 hash of the host's best owned block
}

NodeInfo represents a short summary of the Abeychain sub-protocol metadata known about the host peer.

type PbftAgent

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

PbftAgent receive events from election and communicate with pbftServer

func NewPbftAgent

func NewPbftAgent(abey Backend, config *params.ChainConfig, engine consensus.Engine, election *elect.Election, gasFloor, gasCeil uint64) *PbftAgent

NewPbftAgent creates a new pbftAgent ,receive events from election and communicate with pbftServer

func (*PbftAgent) AcquireCommitteeAuth

func (agent *PbftAgent) AcquireCommitteeAuth(fastHeight *big.Int) bool

AcquireCommitteeAuth determine whether the node pubKey is in the specified committee

func (*PbftAgent) AddRemoteNodeInfo

func (agent *PbftAgent) AddRemoteNodeInfo(cryNodeInfo *types.EncryptNodeMessage) error

AddRemoteNodeInfo send cryNodeInfo of committeeNode to network,and recieved by other committeenode

func (*PbftAgent) BroadcastConsensus

func (agent *PbftAgent) BroadcastConsensus(fb *types.Block) error

BroadcastConsensus when More than 2/3 signs with agree,

committee Member Reach a consensus  and insert the fastBlock into fastBlockChain

func (*PbftAgent) ChangeCommitteeLeader

func (agent *PbftAgent) ChangeCommitteeLeader(height *big.Int) bool

ChangeCommitteeLeader trigger view change.

func (*PbftAgent) CommitteeNumber

func (agent *PbftAgent) CommitteeNumber() uint64

CommitteeNumber return current committee number

func (*PbftAgent) FetchFastBlock

func (agent *PbftAgent) FetchFastBlock(committeeID *big.Int, infos []*types.CommitteeMember) (*types.Block, error)

FetchFastBlock generate fastBlock as leader

func (*PbftAgent) GenerateSign

func (agent *PbftAgent) GenerateSign(fb *types.Block) (*types.PbftSign, error)

GenerateSign generate sign with default agree from committeeMember in fastBlock

func (*PbftAgent) GenerateSignWithVote

func (agent *PbftAgent) GenerateSignWithVote(fb *types.Block, vote uint32, result bool) (*types.PbftSign, error)

GenerateSignWithVote generate sign from committeeMember in fastBlock

func (*PbftAgent) GetAlternativeCommittee

func (agent *PbftAgent) GetAlternativeCommittee() []string

GetAlternativeCommittee return received back committee member's pubkey information

func (*PbftAgent) GetCommitteeNumber

func (agent *PbftAgent) GetCommitteeNumber(blockHeight *big.Int) int32

GetCommitteeNumber get Committees number from blockHeight

func (*PbftAgent) GetCommitteeStatus

func (agent *PbftAgent) GetCommitteeStatus() map[string]interface{}

GetCommitteeStatus return current committee infomation

func (*PbftAgent) GetCurrentCommittee

func (agent *PbftAgent) GetCurrentCommittee() []string

GetCurrentCommittee return committee member's pubkey information

func (*PbftAgent) GetCurrentHeight

func (agent *PbftAgent) GetCurrentHeight() *big.Int

GetCurrentHeight return current fastBlock number

func (*PbftAgent) GetFastLastProposer

func (agent *PbftAgent) GetFastLastProposer() common.Address

GetFastLastProposer get last proposer

func (*PbftAgent) GetNodeInfoByHash

func (agent *PbftAgent) GetNodeInfoByHash(nodeInfoHash common.Hash) (*types.EncryptNodeMessage, bool)

GetNodeInfoByHash get cryptoNodeInfo by hash

func (*PbftAgent) GetPrivateKey

func (agent *PbftAgent) GetPrivateKey() *ecdsa.PrivateKey

GetAlternativeCommittee return received back committee member's pubkey information

func (*PbftAgent) GetSeedMember

func (agent *PbftAgent) GetSeedMember() []*types.CommitteeMember

GetSeedMember get seed member

func (*PbftAgent) GetSnailRewardContent

func (agent *PbftAgent) GetSnailRewardContent(rewardSnailHegiht uint64) *types.SnailRewardContenet

func (*PbftAgent) IsCommitteeMember

func (agent *PbftAgent) IsCommitteeMember() bool

IsCurrentCommitteeMember get whether self is committee member or not

func (*PbftAgent) IsLeader

func (agent *PbftAgent) IsLeader() bool

IsLeader get current committee leader

func (*PbftAgent) IsUsedOrUnusedMember

func (agent *PbftAgent) IsUsedOrUnusedMember(committeeInfo *types.CommitteeInfo, publickey []byte) bool

IsUsedOrUnusedMember whether publickey in committee member

func (*PbftAgent) MarkBroadcastNodeTag

func (agent *PbftAgent) MarkBroadcastNodeTag(cryptoNodeInfo *types.EncryptNodeMessage)

MarkNodeTag Mark received nodeTag,avoid old node information

func (*PbftAgent) MarkNodeInfo

func (agent *PbftAgent) MarkNodeInfo(encryptNode *types.EncryptNodeMessage, nodeTagHash common.Hash)

MarkNodeInfo Mark received NodeInfo

func (*PbftAgent) MarkNodeTag

func (agent *PbftAgent) MarkNodeTag(nodeTag common.Hash, timestamp *big.Int)

MarkNodeTag Mark received nodeTag,avoid old node information

func (*PbftAgent) Start

func (agent *PbftAgent) Start()

Start means receive events from election and send pbftNode infomation

func (*PbftAgent) SubscribeNewPbftSignEvent

func (agent *PbftAgent) SubscribeNewPbftSignEvent(ch chan<- types.PbftSignEvent) event.Subscription

SubscribeNewPbftSignEvent registers a subscription of PbftSignEvent and starts sending event to the given channel.

func (*PbftAgent) SubscribeNodeInfoEvent

func (agent *PbftAgent) SubscribeNodeInfoEvent(ch chan<- types.NodeInfoEvent) event.Subscription

SubscribeNodeInfoEvent registers a subscription of NodeInfoEvent.

func (*PbftAgent) VerifyCommitteeSign

func (agent *PbftAgent) VerifyCommitteeSign(sign *types.PbftSign) bool

VerifyCommitteeSign verify sign of node is in committee

func (*PbftAgent) VerifyFastBlock

func (agent *PbftAgent) VerifyFastBlock(fb *types.Block, result bool) (*types.PbftSign, error)

VerifyFastBlock committee member verify fastBlock and vote agree or disagree sign

type PeerInfo

type PeerInfo struct {
	Version    int      `json:"version"`    // Abeychain protocol version negotiated
	Difficulty *big.Int `json:"difficulty"` // Total difficulty of the peer's blockchain
	Head       string   `json:"head"`       // SHA3 hash of the peer's best owned block
}

PeerInfo represents a short summary of the Abeychain sub-protocol metadata known about a connected peer.

type PrivateAdminAPI

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

PrivateAdminAPI is the collection of Abeychain full node-related APIs exposed over the private admin endpoint.

func NewPrivateAdminAPI

func NewPrivateAdminAPI(abey *Abeychain) *PrivateAdminAPI

NewPrivateAdminAPI creates a new API definition for the full node private admin methods of the Abeychain service.

func (*PrivateAdminAPI) ExportChain

func (api *PrivateAdminAPI) ExportChain(file string) (bool, error)

ExportChain exports the current blockchain into a local file.

func (*PrivateAdminAPI) ImportChain

func (api *PrivateAdminAPI) ImportChain(file string) (bool, error)

ImportChain imports a blockchain from a local file.

type PrivateDebugAPI

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

PrivateDebugAPI is the collection of Abeychain full node APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI

func NewPrivateDebugAPI(config *params.ChainConfig, abey *Abeychain) *PrivateDebugAPI

NewPrivateDebugAPI creates a new API definition for the full node-related private debug methods of the Abeychain service.

func (*PrivateDebugAPI) GetBadBlocks

func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)

GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network and returns them as a JSON list of block-hashes

func (*PrivateDebugAPI) GetModifiedAccountsByHash

func (api *PrivateDebugAPI) GetModifiedAccountsByHash(startHash common.Hash, endHash *common.Hash) ([]common.Address, error)

GetModifiedAccountsByHash returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*PrivateDebugAPI) GetModifiedAccountsByNumber

func (api *PrivateDebugAPI) GetModifiedAccountsByNumber(startNum uint64, endNum *uint64) ([]common.Address, error)

GetModifiedAccountsByNumber returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*PrivateDebugAPI) Preimage

func (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

Preimage is a debug API function that returns the preimage for a sha3 hash, if known.

func (*PrivateDebugAPI) StorageRangeAt

func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error)

StorageRangeAt returns the storage at the given block height and transaction index.

func (*PrivateDebugAPI) TraceBlock

func (api *PrivateDebugAPI) TraceBlock(ctx context.Context, blob []byte, config *TraceConfig) ([]*txTraceResult, error)

TraceBlock returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockByHash

func (api *PrivateDebugAPI) TraceBlockByHash(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByHash returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockByNumber

func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByNumber returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockFromFile

func (api *PrivateDebugAPI) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockFromFile returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceChain

func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error)

TraceChain returns the structured logs created during the execution of EVM between two blocks (excluding start) and returns them as a JSON object.

func (*PrivateDebugAPI) TraceTransaction

func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error)

TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.

type PrivateMinerAPI

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

PrivateMinerAPI provides private RPC methods to control the miner. These methods can be abused by external users and must be considered insecure for use by untrusted users.

func NewPrivateMinerAPI

func NewPrivateMinerAPI(e *Abeychain) *PrivateMinerAPI

NewPrivateMinerAPI create a new RPC service which controls the miner of this node.

func (*PrivateMinerAPI) GetHashRate

func (api *PrivateMinerAPI) GetHashRate() uint64

GetHashRate returns the current hashrate of the miner.

func (*PrivateMinerAPI) SetElection

func (api *PrivateMinerAPI) SetElection(toElect bool, pubkey []byte) (bool, error)

SetElection sets the election .

func (*PrivateMinerAPI) SetEtherbase

func (api *PrivateMinerAPI) SetEtherbase(etherbase common.Address) bool

SetEtherbase sets the etherbase of the miner

func (*PrivateMinerAPI) SetExtra

func (api *PrivateMinerAPI) SetExtra(extra string) (bool, error)

SetExtra sets the extra data string that is included when this miner mines a block.

func (*PrivateMinerAPI) SetGasPrice

func (api *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool

SetGasPrice sets the minimum accepted gas price for the miner.

func (*PrivateMinerAPI) Start

func (api *PrivateMinerAPI) Start(threads *int) error

Start the miner with the given number of threads. If threads is nil the number of workers started is equal to the number of logical CPUs that are usable by this process. If mining is already running, this method adjust the number of threads allowed to use.

func (*PrivateMinerAPI) StartFruit

func (api *PrivateMinerAPI) StartFruit(threads *int) error

func (*PrivateMinerAPI) Stop

func (api *PrivateMinerAPI) Stop() bool

Stop the miner

type ProtocolManager

type ProtocolManager struct {
	SnailPool SnailPool

	SubProtocols []p2p.Protocol
	// contains filtered or unexported fields
}

func NewProtocolManager

func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkID uint64, mux *event.TypeMux, txpool txPool, SnailPool SnailPool, engine consensus.Engine, blockchain *core.BlockChain, snailchain *snailchain.SnailBlockChain, chaindb abeydb.Database, agent *PbftAgent) (*ProtocolManager, error)

NewProtocolManager returns a new Abeychain sub protocol manager. The Abeychain sub protocol manages peers capable with the Abeychain network.

func (*ProtocolManager) BroadcastFastBlock

func (pm *ProtocolManager) BroadcastFastBlock(block *types.Block, propagate bool)

BroadcastFastBlock will either propagate a block to a subset of it's peers, or will only announce it's availability (depending what's requested).

func (*ProtocolManager) BroadcastFruits

func (pm *ProtocolManager) BroadcastFruits(fruits types.Fruits)

BroadcastFruits will propagate a batch of fruits to all peers which are not known to already have the given fruit.

func (*ProtocolManager) BroadcastPbNodeInfo

func (pm *ProtocolManager) BroadcastPbNodeInfo(nodeInfo *types.EncryptNodeMessage)

BroadcastPbNodeInfo will propagate a batch of EncryptNodeMessage to all peers which are not known to already have the given CryNodeInfo.

func (*ProtocolManager) BroadcastPbSign

func (pm *ProtocolManager) BroadcastPbSign(pbSigns []*types.PbftSign)

BroadcastPbSign will propagate a batch of PbftVoteSigns to all peers which are not known to already have the given PbftVoteSign.

func (*ProtocolManager) BroadcastSnailBlock

func (pm *ProtocolManager) BroadcastSnailBlock(snailBlock *types.SnailBlock, propagate bool)

BroadcastSnailBlock will either propagate a snailBlock to a subset of it's peers, or will only announce it's availability (depending what's requested).

func (*ProtocolManager) BroadcastTxs

func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)

BroadcastTxs will propagate a batch of transactions to all peers which are not known to already have the given transaction.

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo() *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

func (*ProtocolManager) Start2

func (pm *ProtocolManager) Start2(maxPeers int)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

type PublicAbeychainAPI

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

PublicAbeychainAPI provides an API to access Abeychain full node-related information.

func NewPublicAbeychainAPI

func NewPublicAbeychainAPI(e *Abeychain) *PublicAbeychainAPI

NewPublicAbeychainAPI creates a new Abeychain protocol API for full nodes.

func (*PublicAbeychainAPI) ChainId

func (api *PublicAbeychainAPI) ChainId() hexutil.Uint64

ChainId retuurn current abeychain's chain config.

func (*PublicAbeychainAPI) Coinbase

func (api *PublicAbeychainAPI) Coinbase() (common.Address, error)

Coinbase is the address that mining rewards will be send to (alias for Etherbase)

func (*PublicAbeychainAPI) CommitteeBase

func (api *PublicAbeychainAPI) CommitteeBase() common.Address

CommitteeBase is the address that generate by pubkey

func (*PublicAbeychainAPI) CommitteeNumber

func (api *PublicAbeychainAPI) CommitteeNumber() uint64

CommitteeNumber return number of current committee

func (*PublicAbeychainAPI) Etherbase

func (api *PublicAbeychainAPI) Etherbase() (common.Address, error)

Etherbase is the address that mining rewards will be send to

func (*PublicAbeychainAPI) GetCurrentState

func (api *PublicAbeychainAPI) GetCurrentState() map[string]interface{}

GetCurrentState get current committee state

func (*PublicAbeychainAPI) Hashrate

func (api *PublicAbeychainAPI) Hashrate() hexutil.Uint64

Hashrate returns the POW hashrate

func (*PublicAbeychainAPI) IsCommitteeMember

func (api *PublicAbeychainAPI) IsCommitteeMember() bool

IsCommitteeMember return node whether current committee member

func (*PublicAbeychainAPI) Pubkey

func (api *PublicAbeychainAPI) Pubkey() string

Pubkey is the address that mining rewards will be send to (alias for Etherbase)

type PublicDebugAPI

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

PublicDebugAPI is the collection of Abeychain full node APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI

func NewPublicDebugAPI(abey *Abeychain) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the full node- related public debug methods of the Abeychain service.

func (*PublicDebugAPI) DumpBlock

func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error)

DumpBlock retrieves the entire state of the database at a given block.

type PublicMinerAPI

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

PublicMinerAPI provides an API to control the miner. It offers only methods that operate on data that pose no security risk when it is publicly accessible.

func NewPublicMinerAPI

func NewPublicMinerAPI(e *Abeychain) *PublicMinerAPI

NewPublicMinerAPI create a new PublicMinerAPI instance.

func (*PublicMinerAPI) GetDataset

func (api *PublicMinerAPI) GetDataset() ([10240]string, error)

GetDataset returns a work package for external miner. The work package consists of 3 strings

func (*PublicMinerAPI) GetDatasetBySeedhash

func (api *PublicMinerAPI) GetDatasetBySeedhash(seedhash string) ([10240]string, error)

GetDataset returns a work package for external miner. The work package consists of 3 strings

func (*PublicMinerAPI) GetWork

func (api *PublicMinerAPI) GetWork() ([4]string, error)

GetWork returns a work package for external miner. The work package consists of 3 strings result[0], 32 bytes hex encoded current block header pow-hash result[1], 32 bytes hex encoded seed hash used for DAG result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty

func (*PublicMinerAPI) Mining

func (api *PublicMinerAPI) Mining() bool

Mining returns an indication if this node is currently mining.

func (*PublicMinerAPI) SubmitHashrate

func (api *PublicMinerAPI) SubmitHashrate(hashrate rpc.HexNumber, id common.Hash) bool

SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined hash rate of all miners which submit work through this node. It accepts the miner hash rate and an identifier which must be unique between nodes.

func (*PublicMinerAPI) SubmitWork

func (api *PublicMinerAPI) SubmitWork(nonce types.BlockNonce, solution, digest common.Hash) bool

SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was accepted. Note, this is not an indication if the provided work was valid!

type SnailPool

type SnailPool interface {
	// AddRemoteFruits should add the given fruits to the pool.
	AddRemoteFruits([]*types.SnailBlock, bool) []error

	// PendingFruits should return pending fruits.
	PendingFruits() map[common.Hash]*types.SnailBlock

	// SubscribeNewFruitEvent should return an event subscription of
	// NewFruitsEvent and send events to the given channel.
	SubscribeNewFruitEvent(chan<- types.NewFruitsEvent) event.Subscription

	RemovePendingFruitByFastHash(fasthash common.Hash)
}

type StorageRangeResult

type StorageRangeResult struct {
	Storage storageMap   `json:"storage"`
	NextKey *common.Hash `json:"nextKey"` // nil if Storage includes the last key in the trie.
}

StorageRangeResult is the result of a debug_storageRangeAt API call.

type TraceConfig

type TraceConfig struct {
	*vm.LogConfig
	Tracer  *string
	Timeout *string
	Reexec  *uint64
}

TraceConfig holds extra parameters to trace functions.

type ULCConfig

type ULCConfig struct {
	TrustedServers     []string `toml:",omitempty"` // A list of trusted servers
	MinTrustedFraction int      `toml:",omitempty"` // Minimum percentage of connected trusted servers to validate trusted (1-100)
}

ULCConfig is a Ultra Light client options.

Directories

Path Synopsis
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package fetcher contains the block announcement based synchronisation.
Package fetcher contains the block announcement based synchronisation.
snail
Package fetcher contains the block announcement based synchronisation.
Package fetcher contains the block announcement based synchronisation.
Package filters implements an ethereum filtering system for block, transactions and log events.
Package filters implements an ethereum filtering system for block, transactions and log events.
Package tracers is a collection of JavaScript transaction tracers.
Package tracers is a collection of JavaScript transaction tracers.
internal/tracers
Package tracers contains the actual JavaScript tracer assets.
Package tracers contains the actual JavaScript tracer assets.

Jump to

Keyboard shortcuts

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