bchain

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: GPL-3.0 Imports: 53 Imported by: 0

Documentation

Overview

Package bchain implements the Bchain protocol.

Package bchain implements the bchain protocol.

Index

Constants

View Source
const (
	StatusMsg          = 0x00
	NewBlockHashesMsg  = 0x01
	TxMsg              = 0x02
	GetBlockHeadersMsg = 0x03
	BlockHeadersMsg    = 0x04
	GetBlockBodiesMsg  = 0x05
	BlockBodiesMsg     = 0x06
	NewBlockMsg        = 0x07

	GetNodeDataMsg = 0x0d
	NodeDataMsg    = 0x0e
	GetReceiptsMsg = 0x0f
	ReceiptsMsg    = 0x10

	CsMsg = 0x20
	BpMsg = 0x21
	BaMsg = 0x22

	GetBlockCertificateMsg = 0x23
	BlockCertificateMsg    = 0x24
)

bchain protocol message codes

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

Variables

View Source
var DefaultConfig = Config{
	SyncMode: downloader.FastSync,

	NetworkId:     1,
	LightPeers:    20,
	DatabaseCache: 128,

	TxPool: txprocessor.DefaultTxPoolConfig,
}

DefaultConfig contains default settings for use on the Bchain main net.

View Source
var ProtocolLengths = []uint64{38}

Number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "bchain"

Official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{bchain63}

Supported versions of the bchain protocol (first is primary).

Functions

func CreateConsensusEngine

func CreateConsensusEngine(bchain *Bchain) consensus.Engine

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

func CreateDB

func CreateDB(ctx *node.ServiceContext, config *Config, name string) (database.IDatabase, error)

CreateDB creates the chain database.

func UpgradeDeduplicateData

func UpgradeDeduplicateData(db database.IDatabase) func() error

Types

type Bchain

type Bchain struct {
	ApiBackend *BchainApiBackend
	// contains filtered or unexported fields
}

Bchain implements the Bchain full node service.

func New

func New(ctx *node.ServiceContext) (*Bchain, error)

New creates a new Bchain object (including the initialisation of the common Bchain object)----Move to bchain2.go

func (*Bchain) APIs

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

func (*Bchain) AccountManager

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

func (*Bchain) AddLesServer

func (s *Bchain) AddLesServer(ls LesServer)

func (*Bchain) BchainVersion

func (s *Bchain) BchainVersion() int

func (*Bchain) BlockChain

func (s *Bchain) BlockChain() *blockchain.BlockChain

func (*Bchain) Blockproducer

func (s *Bchain) Blockproducer() *blockproducer.Blockproducer

func (*Bchain) ChainDb

func (s *Bchain) ChainDb() database.IDatabase

func (*Bchain) Coinbase

func (s *Bchain) Coinbase() (eb accounts.Account, err error)

func (*Bchain) Downloader

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

func (*Bchain) Engine

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

func (*Bchain) EventMux

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

func (*Bchain) IsListening

func (s *Bchain) IsListening() bool

func (*Bchain) IsProducing

func (s *Bchain) IsProducing() bool

func (*Bchain) NetVersion

func (s *Bchain) NetVersion() uint64

func (*Bchain) Protocols

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

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

func (*Bchain) ResetWithGenesisBlock

func (s *Bchain) ResetWithGenesisBlock(gb *block.Block)

func (*Bchain) SetCoinbase

func (self *Bchain) SetCoinbase(coinbase types.Address)

set in js console via admin interface or wrapper from cli flags

func (*Bchain) SetEngineKey

func (s *Bchain) SetEngineKey(pri *ecdsa.PrivateKey)

func (*Bchain) Start

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

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

func (*Bchain) StartProducing

func (s *Bchain) StartProducing(local bool, password string) error

func (*Bchain) Stop

func (s *Bchain) Stop() error

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

func (*Bchain) StopProducing

func (s *Bchain) StopProducing()

func (*Bchain) TxPool

func (s *Bchain) TxPool() *txprocessor.TxPool

type BchainApiBackend

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

BchainApiBackend implements bchainapi.Backend for full nodes

func (*BchainApiBackend) AccountManager

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

func (*BchainApiBackend) BlockByNumber

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

func (*BchainApiBackend) BloomStatus

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

func (*BchainApiBackend) ChainConfig

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

func (*BchainApiBackend) ChainDb

func (b *BchainApiBackend) ChainDb() database.IDatabase

func (*BchainApiBackend) CurrentBlock

func (b *BchainApiBackend) CurrentBlock() *block.Block

func (*BchainApiBackend) CurrentBlockNum

func (b *BchainApiBackend) CurrentBlockNum() uint64

func (*BchainApiBackend) Downloader

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

func (*BchainApiBackend) EventMux

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

func (*BchainApiBackend) GetBlock

func (b *BchainApiBackend) GetBlock(ctx context.Context, blockHash types.Hash) (*block.Block, error)

func (*BchainApiBackend) GetBlockCertificate

func (b *BchainApiBackend) GetBlockCertificate(ctx context.Context, blockNr rpc.BlockNumber) apos.BlockCertificate

func (*BchainApiBackend) GetPoolNonce

func (b *BchainApiBackend) GetPoolNonce(ctx context.Context, addr types.Address) (uint64, error)

func (*BchainApiBackend) GetPoolTransaction

func (b *BchainApiBackend) GetPoolTransaction(hash types.Hash) *transaction.Transaction

func (*BchainApiBackend) GetPoolTransactions

func (b *BchainApiBackend) GetPoolTransactions() (transaction.Transactions, error)

func (*BchainApiBackend) GetReceipts

func (b *BchainApiBackend) GetReceipts(ctx context.Context, blockHash types.Hash) (transaction.Receipts, error)

func (*BchainApiBackend) HeaderByNumber

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

func (*BchainApiBackend) ProtocolVersion

func (b *BchainApiBackend) ProtocolVersion() int

func (*BchainApiBackend) SendTx

func (b *BchainApiBackend) SendTx(ctx context.Context, signedTx *transaction.Transaction) error

func (*BchainApiBackend) ServiceFilter

func (b *BchainApiBackend) ServiceFilter(ctx context.Context, session *bloom.MatcherSession)

func (*BchainApiBackend) SetHead

func (b *BchainApiBackend) SetHead(number uint64)

func (*BchainApiBackend) StatInfoByNumber

func (b *BchainApiBackend) StatInfoByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*blockchain.BlockStat, error)

func (*BchainApiBackend) StateAndHeaderByNumber

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

func (*BchainApiBackend) Stats

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

func (*BchainApiBackend) SubscribeChainEvent

func (b *BchainApiBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

func (*BchainApiBackend) SubscribeChainHeadEvent

func (b *BchainApiBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

func (*BchainApiBackend) SubscribeChainSideEvent

func (b *BchainApiBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

func (*BchainApiBackend) SubscribeLogsEvent

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

func (*BchainApiBackend) SubscribeRemovedLogsEvent

func (b *BchainApiBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

func (*BchainApiBackend) SubscribeTxPreEvent

func (b *BchainApiBackend) SubscribeTxPreEvent(ch chan<- core.TxPreEvent) event.Subscription

func (*BchainApiBackend) TxPoolContent

type BchaindConfig

type BchaindConfig struct {
	Bchain Config
	Node   node.Config
}

type BlockBodiesData

type BlockBodiesData struct {
	Bodys []*block.Body
}

blockBodiesData is the network packet for block content distribution.

func (*BlockBodiesData) DecodeMsg

func (z *BlockBodiesData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*BlockBodiesData) EncodeMsg

func (z *BlockBodiesData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*BlockBodiesData) MarshalMsg

func (z *BlockBodiesData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*BlockBodiesData) Msgsize

func (z *BlockBodiesData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BlockBodiesData) UnmarshalMsg

func (z *BlockBodiesData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type BlockCertificateData

type BlockCertificateData struct {
	Certificates [][]byte
}

blockCertificateData is the network packet for block apos certificates.

func (*BlockCertificateData) DecodeMsg

func (z *BlockCertificateData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*BlockCertificateData) EncodeMsg

func (z *BlockCertificateData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*BlockCertificateData) MarshalMsg

func (z *BlockCertificateData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*BlockCertificateData) Msgsize

func (z *BlockCertificateData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BlockCertificateData) UnmarshalMsg

func (z *BlockCertificateData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Config

type Config struct {
	// The genesis block, which is inserted if the database is empty.
	// If nil, the Bchain main net block is used.
	Genesis *genesis.Genesis `toml:"-"`

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

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

	// Database options
	SkipBcVersionCheck bool `toml:"-"`
	DatabaseHandles    int  `toml:"-"`
	DatabaseCache      int

	// Producing-related options
	Coinbase             types.Address `toml:",omitempty"`
	BlockproducerThreads int           `toml:",omitempty"`
	ExtraData            []byte        `toml:",omitempty"`

	// Transaction pool options
	TxPool txprocessor.TxPoolConfig

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

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

	//should we start blockproducer at first
	StartBlockproducerAtStart bool

	// block options
	MaxBlockTxSize uint64
}

func (Config) MarshalTOML

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

func (*Config) SetDefaultConfig

func (c *Config) SetDefaultConfig() error

func (*Config) SetSpecialConfig

func (c *Config) SetSpecialConfig() error

func (*Config) UnmarshalTOML

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

type GetBlockHeadersData

type GetBlockHeadersData struct {
	Origin  HashOrNumber // Block from which to retrieve headers
	Amount  uint64       // Maximum number of headers to retrieve
	Skip    uint64       // Blocks to skip between consecutive headers
	Reverse bool         // Query direction (false = rising towards latest, true = falling towards genesis)
}

getBlockHeadersData represents a block header query.

func (*GetBlockHeadersData) DecodeMsg

func (z *GetBlockHeadersData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*GetBlockHeadersData) EncodeMsg

func (z *GetBlockHeadersData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*GetBlockHeadersData) MarshalMsg

func (z *GetBlockHeadersData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*GetBlockHeadersData) Msgsize

func (z *GetBlockHeadersData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*GetBlockHeadersData) UnmarshalMsg

func (z *GetBlockHeadersData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type HashOrNumber

type HashOrNumber struct {
	Hash   types.Hash // Block hash from which to retrieve headers (excludes Number)
	Number uint64     // Block hash from which to retrieve headers (excludes Hash)
}

hashOrNumber is a combined field for specifying an origin block.

func (*HashOrNumber) DecodeMsg

func (z *HashOrNumber) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*HashOrNumber) EncodeMsg

func (z *HashOrNumber) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*HashOrNumber) MarshalMsg

func (z *HashOrNumber) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*HashOrNumber) Msgsize

func (z *HashOrNumber) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*HashOrNumber) UnmarshalMsg

func (z *HashOrNumber) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type LesServer

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

type Meta

type Meta struct {
	BlockHash  types.Hash
	BlockIndex uint64
	Index      uint64
}

func (*Meta) DecodeMsg

func (z *Meta) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Meta) EncodeMsg

func (z *Meta) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Meta) MarshalMsg

func (z *Meta) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Meta) Msgsize

func (z *Meta) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Meta) UnmarshalMsg

func (z *Meta) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type NewBlockData

type NewBlockData struct {
	Block  *block.Block
	Number *types.BigInt //block number
}

newBlockData is the network packet for the block propagation message.

func (*NewBlockData) DecodeMsg

func (z *NewBlockData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*NewBlockData) EncodeMsg

func (z *NewBlockData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*NewBlockData) MarshalMsg

func (z *NewBlockData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*NewBlockData) Msgsize

func (z *NewBlockData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*NewBlockData) UnmarshalMsg

func (z *NewBlockData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type NewBlockHashesData

type NewBlockHashesData []struct {
	Hash   types.Hash // Hash of one particular block being announced
	Number uint64     // Number of one particular block being announced
}

newBlockHashesData is the network packet for the block announcements.

func (*NewBlockHashesData) DecodeMsg

func (z *NewBlockHashesData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (NewBlockHashesData) EncodeMsg

func (z NewBlockHashesData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (NewBlockHashesData) MarshalMsg

func (z NewBlockHashesData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (NewBlockHashesData) Msgsize

func (z NewBlockHashesData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*NewBlockHashesData) UnmarshalMsg

func (z *NewBlockHashesData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type NodeData

type NodeData struct {
	Nodes [][]byte
}

func (*NodeData) DecodeMsg

func (z *NodeData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*NodeData) EncodeMsg

func (z *NodeData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*NodeData) MarshalMsg

func (z *NodeData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*NodeData) Msgsize

func (z *NodeData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*NodeData) UnmarshalMsg

func (z *NodeData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type NodeInfo

type NodeInfo struct {
	Network uint64              `json:"network"`    // bchain network ID
	Number  *big.Int            `json:"difficulty"` // height of the host's blockchain
	Genesis types.Hash          `json:"genesis"`    // SHA3 hash of the host's genesis block
	Config  *params.ChainConfig `json:"config"`     // Chain configuration for the fork rules
	Head    types.Hash          `json:"head"`       // SHA3 hash of the host's best owned block
}

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

type PeerInfo

type PeerInfo struct {
	Version int      `json:"version"` // bchain protocol version negotiated
	Number  *big.Int `json:"number"`  // height 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 bchain sub-protocol metadata known about a connected peer.

type PrivateAdminAPI

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

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

func NewPrivateAdminAPI

func NewPrivateAdminAPI(bchain *Bchain) *PrivateAdminAPI

NewPrivateAdminAPI creates a new API definition for the full node private admin methods of the Bchain 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 PrivateBlockproducerAPI

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

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

func NewPrivateBlockproducerAPI

func NewPrivateBlockproducerAPI(e *Bchain) *PrivateBlockproducerAPI

NewPrivateBlockproducerAPI create a new RPC service which controls the blockproducer of this node.

func (*PrivateBlockproducerAPI) GetHashrate

func (api *PrivateBlockproducerAPI) GetHashrate() uint64

GetHashrate returns the current hashrate of the blockproducer.

func (*PrivateBlockproducerAPI) SetCoinbase

func (api *PrivateBlockproducerAPI) SetCoinbase(coinbase types.Address) bool

SetCoinbase sets the coinbase of the blockproducer

func (*PrivateBlockproducerAPI) SetExtra

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

SetExtra sets the extra data string that is included when this blockproducer produces a block.

func (*PrivateBlockproducerAPI) Start

func (api *PrivateBlockproducerAPI) Start(threads *int, password string) error

Start the blockproducer 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 producing is already running, this method adjust the number of threads allowed to use.

func (*PrivateBlockproducerAPI) Stop

func (api *PrivateBlockproducerAPI) Stop() bool

Stop the blockproducer

type ProtocolManager

type ProtocolManager struct {
	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, engine consensus.Engine, blockchain *blockchain.BlockChain, chaindb database.IDatabase, aPos *apos.Apos) (*ProtocolManager, error)

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

func (*ProtocolManager) BroadcastBa

func (pm *ProtocolManager) BroadcastBa(hash types.Hash, ba *apos.ByzantineAgreementStar)

func (*ProtocolManager) BroadcastBlock

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

BroadcastBlock 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) BroadcastBp

func (pm *ProtocolManager) BroadcastBp(hash types.Hash, bp *apos.BlockProposal)

func (*ProtocolManager) BroadcastCs

func (pm *ProtocolManager) BroadcastCs(hash types.Hash, cs *apos.CredentialSign)

func (*ProtocolManager) BroadcastTx

func (pm *ProtocolManager) BroadcastTx(hash types.Hash, tx *transaction.Transaction)

BroadcastTx will propagate a transaction to all peers which are not known to already have the given transaction.

func (*ProtocolManager) NodeInfo

func (self *ProtocolManager) NodeInfo() *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

type PublicBchainAPI

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

PublicBchainAPI provides an API to access Bchain full node-related information.

func NewPublicBchainAPI

func NewPublicBchainAPI(e *Bchain) *PublicBchainAPI

NewPublicBchainAPI creates a new Bchain protocol API for full nodes.

func (*PublicBchainAPI) Coinbase

func (api *PublicBchainAPI) Coinbase() (types.Address, error)

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

func (*PublicBchainAPI) Hashrate

func (api *PublicBchainAPI) Hashrate() types.Uint64ForJson

Hashrate returns the POW hashrate

type SetupGenesisResult

type SetupGenesisResult struct {
	ChainConfig  *params.ChainConfig
	GennesisHash *types.Hash
	GenesisErr   error
	ChainDb      *database.IDatabase
}

type StatusData

type StatusData struct {
	ProtocolVersion uint32
	NetworkId       uint64
	Number          *types.BigInt //current chain height
	CurrentBlock    types.Hash
	GenesisBlock    types.Hash
}

statusData is the network packet for the status message.

func (*StatusData) DecodeMsg

func (z *StatusData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*StatusData) EncodeMsg

func (z *StatusData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*StatusData) MarshalMsg

func (z *StatusData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*StatusData) Msgsize

func (z *StatusData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*StatusData) UnmarshalMsg

func (z *StatusData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type StorageRangeResult

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

StorageRangeResult is the result of a debug_storageRangeAt API call.

Directories

Path Synopsis
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package filters implements an bchain filtering system for block, transactions and log events.
Package filters implements an bchain filtering system for block, transactions and log events.

Jump to

Keyboard shortcuts

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