exp

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2016 License: GPL-3.0 Imports: 42 Imported by: 0

Documentation

Overview

Package exp implements the Expanse protocol.

Index

Constants

View Source
const (
	NetworkId          = 1
	ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
View Source
const (
	// Protocol messages belonging to eth/61
	StatusMsg                   = 0x00
	NewBlockHashesMsg           = 0x01
	TxMsg                       = 0x02
	GetBlockHashesMsg           = 0x03
	BlockHashesMsg              = 0x04
	GetBlocksMsg                = 0x05
	BlocksMsg                   = 0x06
	NewBlockMsg                 = 0x07
	GetBlockHashesFromNumberMsg = 0x08

	// Protocol messages belonging to eth/62 (new protocol from scratch)
	// StatusMsg          = 0x00 (uncomment after eth/61 deprecation)
	// NewBlockHashesMsg  = 0x01 (uncomment after eth/61 deprecation)
	// TxMsg              = 0x02 (uncomment after eth/61 deprecation)
	GetBlockHeadersMsg = 0x03
	BlockHeadersMsg    = 0x04
	GetBlockBodiesMsg  = 0x05
	BlockBodiesMsg     = 0x06

	// Protocol messages belonging to eth/63
	GetNodeDataMsg = 0x0d
	NodeDataMsg    = 0x0e
	GetReceiptsMsg = 0x0f
	ReceiptsMsg    = 0x10
)

exp protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
)

Variables

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

Number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "exp"

Official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{eth63, eth62, eth61}

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

Functions

func GPUBench

func GPUBench(gpuid uint64)

func PrintOpenCLDevices

func PrintOpenCLDevices()

Types

type Config

type Config struct {
	DevMode bool
	TestNet bool

	Name         string
	NetworkId    int
	GenesisFile  string
	GenesisBlock *types.Block // used by block tests
	FastSync     bool
	Olympic      bool

	BlockChainVersion  int
	SkipBcVersionCheck bool // e.g. blockchain export
	DatabaseCache      int

	DataDir   string
	LogFile   string
	Verbosity int
	VmDebug   bool
	NatSpec   bool
	DocRoot   string
	AutoDAG   bool
	PowTest   bool
	ExtraData []byte

	MaxPeers        int
	MaxPendingPeers int
	Discovery       bool
	Port            string

	// Space-separated list of discovery node URLs
	BootNodes string

	// This key is used to identify the node on the network.
	// If nil, an ephemeral key is used.
	NodeKey *ecdsa.PrivateKey

	NAT  nat.Interface
	Shh  bool
	Dial bool

	Etherbase      common.Address
	GasPrice       *big.Int
	MinerThreads   int
	AccountManager *accounts.Manager
	SolcPath       string

	GpoMinGasPrice          *big.Int
	GpoMaxGasPrice          *big.Int
	GpoFullBlockRatio       int
	GpobaseStepDown         int
	GpobaseStepUp           int
	GpobaseCorrectionFactor int

	// NewDB is used to create databases.
	// If nil, the default is to create leveldb databases on disk.
	NewDB func(path string) (ethdb.Database, error)
}

type EthNodeInfo

type EthNodeInfo struct {
	Network    int      `json:"network"`    // Ethereum network ID (0=Olympic, 1=Frontier, 2=Morden)
	Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain
	Genesis    string   `json:"genesis"`    // SHA3 hash of the host's genesis block
	Head       string   `json:"head"`       // SHA3 hash of the host's best owned block
}

EthNodeInfo represents a short summary of the Ethereum sub-protocol metadata known about the host peer.

type Expanse

type Expanse struct {
	SolcPath string

	GpoMinGasPrice          *big.Int
	GpoMaxGasPrice          *big.Int
	GpoFullBlockRatio       int
	GpobaseStepDown         int
	GpobaseStepUp           int
	GpobaseCorrectionFactor int

	Mining       bool
	MinerThreads int
	NatSpec      bool
	DataDir      string
	AutoDAG      bool
	PowTest      bool
	// contains filtered or unexported fields
}

func New

func New(config *Config) (*Expanse, error)

func (*Expanse) AccountManager

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

func (*Expanse) AddPeer

func (self *Expanse) AddPeer(nodeURL string) error

AddPeer connects to the given node and maintains the connection until the server is shut down. If the connection fails for any reason, the server will attempt to reconnect the peer.

func (*Expanse) BlockChain

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

func (*Expanse) ChainDb

func (s *Expanse) ChainDb() ethdb.Database

func (*Expanse) ClientVersion

func (s *Expanse) ClientVersion() string

func (*Expanse) DappDb

func (s *Expanse) DappDb() ethdb.Database

func (*Expanse) Downloader

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

func (*Expanse) EthVersion

func (s *Expanse) EthVersion() int

func (*Expanse) Etherbase

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

func (*Expanse) EventMux

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

func (*Expanse) HTTPClient

func (self *Expanse) HTTPClient() *httpclient.HTTPClient

HTTPClient returns the light http client used for fetching offchain docs (natspec, source for verification)

func (*Expanse) IsListening

func (s *Expanse) IsListening() bool

func (*Expanse) IsMining

func (s *Expanse) IsMining() bool

func (*Expanse) MaxPeers

func (s *Expanse) MaxPeers() int

func (*Expanse) Miner

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

func (*Expanse) Name

func (s *Expanse) Name() string

func (s *Expanse) Logger() logger.LogSystem { return s.logger }

func (*Expanse) NetVersion

func (s *Expanse) NetVersion() int

func (*Expanse) Network

func (s *Expanse) Network() *p2p.Server

Network retrieves the underlying P2P network server. This should eventually be moved out into a protocol independent package, but for now use an accessor.

func (*Expanse) PeerCount

func (s *Expanse) PeerCount() int

func (*Expanse) Peers

func (s *Expanse) Peers() []*p2p.Peer

func (*Expanse) ResetWithGenesisBlock

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

func (*Expanse) SetEtherbase

func (self *Expanse) SetEtherbase(etherbase common.Address)

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

func (*Expanse) SetSolc

func (self *Expanse) SetSolc(solcPath string) (*compiler.Solidity, error)

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

func (*Expanse) ShhVersion

func (s *Expanse) ShhVersion() int

func (*Expanse) Solc

func (self *Expanse) Solc() (*compiler.Solidity, error)

func (*Expanse) Start

func (s *Expanse) Start() error

Start the ethereum

func (*Expanse) StartAutoDAG

func (self *Expanse) StartAutoDAG()

StartAutoDAG() spawns a go routine that checks the DAG every autoDAGcheckInterval by default that is 10 times per epoch in epoch n, if we past autoDAGepochHeight within-epoch blocks, it calls ethash.MakeDAG to pregenerate the DAG for the next epoch n+1 if it does not exist yet as well as remove the DAG for epoch n-1 the loop quits if autodagquit channel is closed, it can safely restart and stop any number of times. For any more sophisticated pattern of DAG generation, use CLI subcommand makedag

func (*Expanse) StartForTest

func (s *Expanse) StartForTest()

func (*Expanse) StartMining

func (s *Expanse) StartMining(threads int, gpus string) error

func (*Expanse) Stop

func (s *Expanse) Stop()

func (*Expanse) StopAutoDAG

func (self *Expanse) StopAutoDAG()

stopAutoDAG stops automatic DAG pregeneration by quitting the loop

func (*Expanse) StopMining

func (s *Expanse) StopMining()

func (*Expanse) TxPool

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

func (*Expanse) WaitForShutdown

func (s *Expanse) WaitForShutdown()

This function will wait for a shutdown and resumes main thread execution

func (*Expanse) Whisper

func (s *Expanse) Whisper() *whisper.Whisper

type GasPriceOracle

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

GasPriceOracle recommends gas prices based on the content of recent blocks.

func NewGasPriceOracle

func NewGasPriceOracle(exp *Expanse) *GasPriceOracle

NewGasPriceOracle returns a new oracle.

func (*GasPriceOracle) SuggestPrice

func (self *GasPriceOracle) SuggestPrice() *big.Int

SuggestPrice returns the recommended gas price.

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(fastSync bool, networkId int, mux *event.TypeMux, txpool txPool, pow pow.PoW, blockchain *core.BlockChain, chaindb ethdb.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) BroadcastTx

func (pm *ProtocolManager) BroadcastTx(hash common.Hash, tx *types.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() *EthNodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start()

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

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 synchonisation.
Package fetcher contains the block announcement based synchonisation.
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.

Jump to

Keyboard shortcuts

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