Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDB(nodeConfig *node.Config, name string, cache, handlers int) (youdb.Database, error)
- func ParseNodes(input []string) []*enode.Node
- type BlocksData
- type Config
- type FallbackHandler
- func (handler *FallbackHandler) AddPeerByAddr(addr string)
- func (handler *FallbackHandler) Config() FallbackHandlerConfig
- func (handler *FallbackHandler) Downloader() *downloader.Downloader
- func (handler *FallbackHandler) GetSubProtocols() []p2p.Protocol
- func (handler *FallbackHandler) Insert(block *types.Block) error
- func (handler *FallbackHandler) Start(p2pserver interface{}, maxPeers int)
- func (handler *FallbackHandler) Stop()
- type FallbackHandlerConfig
- type GenericProtocolManager
- type GetNodeDataMsgData
- type HashOrNumber
- type NewBlockHashesData
- type NodeInfo
- type PeerEvent
- type PeerSet
- func (ps *PeerSet) BestPeer() *peer
- func (ps *PeerSet) Close()
- func (ps *PeerSet) Len() int
- func (ps *PeerSet) Peer(id string) *peer
- func (ps *PeerSet) PeersWithoutBlock(hash common.Hash) []*peer
- func (ps *PeerSet) PeersWithoutTx(hash common.Hash) []*peer
- func (ps *PeerSet) Register(p *peer) error
- func (ps *PeerSet) Unregister(id string) error
- type PrivateMinerApi
- type ProtocolManager
- func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool)
- func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)
- func (pm *ProtocolManager) Downloader() *downloader.Downloader
- func (pm *ProtocolManager) GetSubProtocols() []p2p.Protocol
- func (pm *ProtocolManager) Insert(block *types.Block) error
- func (pm *ProtocolManager) NodeInfo() *NodeInfo
- func (pm *ProtocolManager) Start(p2pserver interface{}, maxPeers int)
- func (pm *ProtocolManager) Stop()
- type RemoteNode
- type UConProtocolManager
- func (um *UConProtocolManager) GetSubProtocols() []p2p.Protocol
- func (um *UConProtocolManager) Insert(block *types.Block) error
- func (um *UConProtocolManager) Start(p2pserver interface{}, maxPeers int)
- func (um *UConProtocolManager) Stop()
- func (um *UConProtocolManager) SubscribePeers(ch chan *PeerEvent) event.Subscription
- type YouChain
- func (you *YouChain) APIs() []rpc.API
- func (you *YouChain) AccountManager() *accounts.Manager
- func (you *YouChain) BlockChain() *core.BlockChain
- func (you *YouChain) ChainDb() youdb.Database
- func (you *YouChain) Config() *Config
- func (you *YouChain) DetailDb() local.DetailDB
- func (you *YouChain) EventMux() *event.TypeMux
- func (you *YouChain) Miner() *miner.Miner
- func (you *YouChain) ProtocolManager() GenericProtocolManager
- func (you *YouChain) Protocols() []p2p.Protocol
- func (you *YouChain) QuitCh() <-chan bool
- func (you *YouChain) SetAccountManager(manager *accounts.Manager)
- func (you *YouChain) Start(server *p2p.Server) error
- func (you *YouChain) StartBloomHandlers(sectionSize uint64)
- func (you *YouChain) StartMining() error
- func (you *YouChain) Stop() error
- func (you *YouChain) StopMining() error
- func (you *YouChain) TxPool() *core.TxPool
- func (you *YouChain) UseValKey(addr common.Address, password string, keep bool) error
- func (you *YouChain) YouVersion() int
Constants ¶
const ( // bloomFilterThreads is the number of goroutines used locally per filter to // multiplex requests onto the global servicing goroutines. BloomFilterThreads = 3 // bloomRetrievalBatch is the maximum number of bloom bit retrievals to service // in a single batch. BloomRetrievalBatch = 16 // bloomRetrievalWait is the maximum time to wait for enough bloom bit requests // to accumulate request an entire batch (avoiding hysteresis). BloomRetrievalWait = time.Duration(0) )
const ( StatusMsg = 0x00 NewBlockMsg = 0x01 NewBlockHashMsg = 0x02 TxMsg = 0x03 GetBlockMsg = 0x04 ConsensusCtrMsg = 0x05 ConsensusMsg = 0x06 GetBlockHeadersMsg = 0x07 // get batch of headers BlockHeadersMsg = 0x08 GetNodeDataMsg = 0x09 // get trie node data NodeDataMsg = 0x0A GetBlockBodiesMsg = 0x0B // get batch of bodies BlockBodiesMsg = 0x0C GetReceiptsMsg = 0x0D // get batch of receipts ReceiptsMsg = 0x0E )
Code must not exceeds the ProtocolLengths
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch ErrNetworkIdMismatch ErrGenesisBlockMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrSuspendedPeer )
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
Variables ¶
var DefaultConfig = Config{ NetworkId: 1, DatabaseCache: 768, TrieCache: 256, DatabaseHandles: 256, MinerGasPrice: new(big.Int).SetUint64(params.DefaultMinGasPrice), TxPool: core.DefaultTxPoolConfig, GPO: gasprice.Config{ Blocks: 20, Percentile: 60, }, }
var ProtocolLengths = []uint64{18}
ProtocolLengths are the number of implemented message corresponding to different protocol versions.
var ProtocolName = "you"
ProtocolName is the official short name of the protocol used during capability negotiation.
var ProtocolVersions = []uint{you8}
ProtocolVersions are the supported versions of the you protocol (first is primary).
Functions ¶
func ParseNodes ¶
Types ¶
type Config ¶
type Config struct { // The genesis block, which is inserted if the database is empty. // If nil, the main net block is used. Genesis *core.Genesis `toml:",omitempty"` NetworkId uint64 //DB DatabaseCache int DatabaseHandles int TrieCache int MinerGasPrice *big.Int // Transaction pool options TxPool core.TxPoolConfig // Gas Price Oracle options GPO gasprice.Config // RPCGasCap is the global gas cap for eth-call variants. RPCGasCap *big.Int `toml:",omitempty"` }
func NewDefaultConfig ¶
func NewDefaultConfig() Config
type FallbackHandler ¶
type FallbackHandler struct {
// contains filtered or unexported fields
}
func NewFallbackHandler ¶
func NewFallbackHandler(configPath string, txPool *core.TxPool, bc *core.BlockChain) *FallbackHandler
func (*FallbackHandler) AddPeerByAddr ¶
func (handler *FallbackHandler) AddPeerByAddr(addr string)
func (*FallbackHandler) Config ¶
func (handler *FallbackHandler) Config() FallbackHandlerConfig
func (*FallbackHandler) Downloader ¶
func (handler *FallbackHandler) Downloader() *downloader.Downloader
func (*FallbackHandler) GetSubProtocols ¶
func (handler *FallbackHandler) GetSubProtocols() []p2p.Protocol
func (*FallbackHandler) Start ¶
func (handler *FallbackHandler) Start(p2pserver interface{}, maxPeers int)
func (*FallbackHandler) Stop ¶
func (handler *FallbackHandler) Stop()
type FallbackHandlerConfig ¶
type GenericProtocolManager ¶
type GenericProtocolManager interface { consensus.MineInserter Start(p2pserver interface{}, maxPeers int) Stop() GetSubProtocols() []p2p.Protocol Downloader() *downloader.Downloader }
for fallback usage
type GetNodeDataMsgData ¶
type HashOrNumber ¶
type HashOrNumber struct { Hash common.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.
type NewBlockHashesData ¶
type NewBlockHashesData []struct { Hash common.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.
type NodeInfo ¶
type NodeInfo struct { Network uint64 `json:"network"` // YOUChain network ID (1=MainNet, 2=PubTestNet) Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Head common.Hash `json:"head"` // SHA3 hash of the host's best owned block }
NodeInfo represents a short summary of the YOUChain sub-protocol metadata known about the host peer.
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
peerSet represents the collection of active peers currently participating in the Ethereum sub-protocol.
func (*PeerSet) BestPeer ¶
func (ps *PeerSet) BestPeer() *peer
BestPeer retrieves the known peer with the currently highest total number.
func (*PeerSet) Close ¶
func (ps *PeerSet) Close()
Close disconnects all peers. No new peers can be registered after Close has returned.
func (*PeerSet) PeersWithoutBlock ¶
PeersWithoutBlock retrieves a list of peers that do not have a given block in their set of known hashes. Starting with trusted peers.
func (*PeerSet) PeersWithoutTx ¶
PeersWithoutTx retrieves a list of peers that do not have a given transaction in their set of known hashes. Only returns those peers whose node type is ArchiveNode or FullNode.
func (*PeerSet) Register ¶
Register injects a new peer into the working set, or returns an error if the peer is already known. If a new peer it registered, its broadcast loop is also started.
func (*PeerSet) Unregister ¶
Unregister removes a remote peer from the active set, disabling any further actions to/from that particular entity.
type PrivateMinerApi ¶
type PrivateMinerApi struct {
// contains filtered or unexported fields
}
func NewPrivateMinerApi ¶
func NewPrivateMinerApi(c *YouChain) *PrivateMinerApi
func (*PrivateMinerApi) Mining ¶
func (api *PrivateMinerApi) Mining() bool
Mining returns an indication if this node is currently mining.
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() error
Start starts the miner and engine for mining. If mining is already running, this method just do nothing.
func (*PrivateMinerApi) Stop ¶
func (api *PrivateMinerApi) Stop() error
type ProtocolManager ¶
type ProtocolManager struct { SubProtocols []p2p.Protocol // contains filtered or unexported fields }
func NewProtocolManager ¶
func NewProtocolManager(txpool txPool, blockchain *core.BlockChain, engine consensus.Engine, mux *event.TypeMux, chaindb youdb.Database, mode downloader.SyncMode) (*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) Downloader ¶
func (pm *ProtocolManager) Downloader() *downloader.Downloader
func (*ProtocolManager) GetSubProtocols ¶
func (pm *ProtocolManager) GetSubProtocols() []p2p.Protocol
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(p2pserver interface{}, maxPeers int)
func (*ProtocolManager) Stop ¶
func (pm *ProtocolManager) Stop()
type RemoteNode ¶
type RemoteNode struct {
// contains filtered or unexported fields
}
type UConProtocolManager ¶
type UConProtocolManager struct { *ProtocolManager // contains filtered or unexported fields }
func NewUConProtocolManager ¶
func NewUConProtocolManager(txpool txPool, blockchain *core.BlockChain, engine consensus.Ucon, mux *event.TypeMux, chainDb youdb.Database, mode downloader.SyncMode) (*UConProtocolManager, error)
func (*UConProtocolManager) GetSubProtocols ¶
func (um *UConProtocolManager) GetSubProtocols() []p2p.Protocol
func (*UConProtocolManager) Insert ¶
func (um *UConProtocolManager) Insert(block *types.Block) error
func (*UConProtocolManager) Start ¶
func (um *UConProtocolManager) Start(p2pserver interface{}, maxPeers int)
func (*UConProtocolManager) Stop ¶
func (um *UConProtocolManager) Stop()
func (*UConProtocolManager) SubscribePeers ¶
func (um *UConProtocolManager) SubscribePeers(ch chan *PeerEvent) event.Subscription
type YouChain ¶
type YouChain struct { BloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests // contains filtered or unexported fields }
func (*YouChain) AccountManager ¶
func (*YouChain) BlockChain ¶
func (you *YouChain) BlockChain() *core.BlockChain
func (*YouChain) ProtocolManager ¶
func (you *YouChain) ProtocolManager() GenericProtocolManager
func (*YouChain) SetAccountManager ¶
func (*YouChain) StartBloomHandlers ¶
startBloomHandlers starts a batch of goroutines to accept bloom bit database retrievals from possibly a range of filters and serving the data to satisfy.