Documentation
¶
Index ¶
- Constants
- Variables
- func CreateConsensusEngine() consensus.Engine
- func CreateDB(ctx *node.ServiceContext, config *Config, name string) (database.Database, error)
- type Config
- type NodeInfo
- type PeerInfo
- type ProtocolManager
- type SilkRoad
- func (s *SilkRoad) AccountManager() *account.AccountManager
- func (s *SilkRoad) BlockChain() *blockchain.BlockChain
- func (s *SilkRoad) ChainDb() database.Database
- func (s *SilkRoad) Coinbase() (cb common.Address, err error)
- func (s *SilkRoad) Engine() consensus.Engine
- func (s *SilkRoad) IsMining() bool
- func (s *SilkRoad) Protocols() []p2p.Protocol
- func (s *SilkRoad) Start(server *p2p.Server) error
- func (s *SilkRoad) StartMining(threads int) error
- func (s *SilkRoad) Stop() error
- func (s *SilkRoad) TxPool() *transaction.TxPool
Constants ¶
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch ErrNetworkIdMismatch ErrGenesisBlockMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrSuspendedPeer )
const ( // Protocol messages belonging to src/63 StatusMsg = 0x00 NewBlockHashesMsg = 0x01 TxMsg = 0x02 GetBlockHeadersMsg = 0x03 BlockHeadersMsg = 0x04 GetBlockBodiesMsg = 0x05 BlockBodiesMsg = 0x06 NewBlockMsg = 0x07 )
eth protocol message codes
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
Variables ¶
var DefaultConfig = Config{
NetworkId: 1,
DatabaseCache: 768,
}
DefaultConfig contains default settings for use on main net.
var ProtocolLengths = []uint64{17, 8}
ProtocolLengths are the number of implemented message corresponding to different protocol versions.
var ProtocolName = "src"
ProtocolName is the official short name of the protocol used during capability negotiation.
var ProtocolVersions = []uint{src63}
ProtocolVersions are the upported versions of the eth protocol (first is primary).
Functions ¶
func CreateConsensusEngine ¶
CreateConsensusEngine creates the required type of consensus engine instance for SilkRoad
Types ¶
type Config ¶
type Config struct {
// The genesis block, which is inserted if the database is empty.
// If nil, main net block is used.
Genesis *blockchain.Genesis `toml:",omitempty"`
// Protocol options
NetworkId uint64 // Network ID to use for selecting peers to connect to
// Database options
DatabaseHandles int `toml:"-"`
DatabaseCache int
// Mining-related options
Coinbase common.Address `toml:",omitempty"`
MinerThreads int `toml:",omitempty"`
ExtraData []byte `toml:",omitempty"`
// Transaction pool options
TxPool mempool.TxPoolConfig
}
type NodeInfo ¶
type NodeInfo struct {
Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain
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
}
NodeInfo represents a short summary of the Ethereum sub-protocol metadata known about the host peer.
type PeerInfo ¶
type PeerInfo struct {
Version int `json:"version"` // Ethereum 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 Ethereum sub-protocol metadata known about a connected peer.
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 *bc.BlockChain, chaindb srcdb.Database) (*ProtocolManager, error)
NewProtocolManager returns a new Ethereum sub protocol manager. The Ethereum sub protocol manages peers capable with the Ethereum network.
func (*ProtocolManager) BroadcastBlock ¶
func (pm *ProtocolManager) BroadcastBlock(block *types.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) 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) Stop ¶
func (pm *ProtocolManager) Stop()
type SilkRoad ¶
type SilkRoad struct {
// contains filtered or unexported fields
}
SilkRoad implements the full node service.
func New ¶
func New(ctx *node.ServiceContext, config *Config) (*SilkRoad, error)
New creates a new SilkRoad object
func (*SilkRoad) AccountManager ¶
func (s *SilkRoad) AccountManager() *account.AccountManager
func (*SilkRoad) BlockChain ¶
func (s *SilkRoad) BlockChain() *blockchain.BlockChain
func (*SilkRoad) Protocols ¶
Protocols implements node.Service, returning all the currently configured network protocols to start.
func (*SilkRoad) Start ¶
SilkRoad protocol implementation. func (s *SilkRoad) Start(srvr *p2p.SilkRoad) error {
func (*SilkRoad) StartMining ¶
StartMining starts the miner with the given number of CPU threads. If mining is already running, this method adjust the number of threads allowed to use.
func (*SilkRoad) Stop ¶
Stop implements node.Service, terminating all internal goroutines used by the SilkRoad protocol.
func (*SilkRoad) TxPool ¶
func (s *SilkRoad) TxPool() *transaction.TxPool
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
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. |