server

package
v0.0.0-...-e4b14ae Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: LGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
)
View Source
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

View Source
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message

Variables

View Source
var DefaultConfig = Config{

	NetworkId: 1,

	DatabaseCache: 768,
}

DefaultConfig contains default settings for use on main net.

View Source
var ProtocolLengths = []uint64{17, 8}

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

View Source
var ProtocolName = "src"

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

View Source
var ProtocolVersions = []uint{src63}

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

Functions

func CreateConsensusEngine

func CreateConsensusEngine() consensus.Engine

CreateConsensusEngine creates the required type of consensus engine instance for SilkRoad

func CreateDB

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

CreateDB creates the chain database.

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) ChainDb

func (s *SilkRoad) ChainDb() database.Database

func (*SilkRoad) Coinbase

func (s *SilkRoad) Coinbase() (cb common.Address, err error)

func (*SilkRoad) Engine

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

func (*SilkRoad) IsMining

func (s *SilkRoad) IsMining() bool

func (*SilkRoad) Protocols

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

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

func (*SilkRoad) Start

func (s *SilkRoad) Start(server *p2p.Server) error

SilkRoad protocol implementation. func (s *SilkRoad) Start(srvr *p2p.SilkRoad) error {

func (*SilkRoad) StartMining

func (s *SilkRoad) StartMining(threads int) error

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

func (s *SilkRoad) Stop() error

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

func (*SilkRoad) TxPool

func (s *SilkRoad) TxPool() *transaction.TxPool

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.

Jump to

Keyboard shortcuts

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