you

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: LGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
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)
)
View Source
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

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{
	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,
	},
}
View Source
var ProtocolLengths = []uint64{18}

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

View Source
var ProtocolName = "you"

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

View Source
var ProtocolVersions = []uint{you8}

ProtocolVersions are the supported versions of the you protocol (first is primary).

Functions

func CreateDB

func CreateDB(nodeConfig *node.Config, name string, cache, handlers int) (youdb.Database, error)

func ParseNodes

func ParseNodes(input []string) []*enode.Node

Types

type BlocksData

type BlocksData []struct {
	Block  *types.Block
	Number *big.Int
}

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

func (handler *FallbackHandler) Insert(block *types.Block) error

func (*FallbackHandler) Start

func (handler *FallbackHandler) Start(p2pserver interface{}, maxPeers int)

func (*FallbackHandler) Stop

func (handler *FallbackHandler) Stop()

type FallbackHandlerConfig

type FallbackHandlerConfig struct {
	Urls       []string `json:"urls"`
	CurrentIdx int      `json:"current_idx"`
}

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 GetNodeDataMsgData struct {
	Kind   types.TrieKind
	Hashes []common.Hash
}

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 PeerEvent

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

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

func (ps *PeerSet) Len() int

Len returns if the current number of peers in the set.

func (*PeerSet) Peer

func (ps *PeerSet) Peer(id string) *peer

Peer retrieves the registered peer with the given id.

func (*PeerSet) PeersWithoutBlock

func (ps *PeerSet) PeersWithoutBlock(hash common.Hash) []*peer

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

func (ps *PeerSet) PeersWithoutTx(hash common.Hash) []*peer

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

func (ps *PeerSet) Register(p *peer) error

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

func (ps *PeerSet) Unregister(id string) error

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

func (pm *ProtocolManager) Insert(block *types.Block) error

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 New

func New(config *Config, nodeConfig *node.Config) (*YouChain, error)

func (*YouChain) APIs

func (you *YouChain) APIs() []rpc.API

func (*YouChain) AccountManager

func (you *YouChain) AccountManager() *accounts.Manager

func (*YouChain) BlockChain

func (you *YouChain) BlockChain() *core.BlockChain

func (*YouChain) ChainDb

func (you *YouChain) ChainDb() youdb.Database

func (*YouChain) Config

func (you *YouChain) Config() *Config

func (*YouChain) DetailDb added in v0.10.0

func (you *YouChain) DetailDb() local.DetailDB

func (*YouChain) EventMux

func (you *YouChain) EventMux() *event.TypeMux

func (*YouChain) Miner

func (you *YouChain) Miner() *miner.Miner

func (*YouChain) ProtocolManager

func (you *YouChain) ProtocolManager() GenericProtocolManager

func (*YouChain) Protocols

func (you *YouChain) Protocols() []p2p.Protocol

func (*YouChain) QuitCh

func (you *YouChain) QuitCh() <-chan bool

func (*YouChain) SetAccountManager

func (you *YouChain) SetAccountManager(manager *accounts.Manager)

func (*YouChain) Start

func (you *YouChain) Start(server *p2p.Server) error

func (*YouChain) StartBloomHandlers

func (you *YouChain) StartBloomHandlers(sectionSize uint64)

startBloomHandlers starts a batch of goroutines to accept bloom bit database retrievals from possibly a range of filters and serving the data to satisfy.

func (*YouChain) StartMining

func (you *YouChain) StartMining() error

func (*YouChain) Stop

func (you *YouChain) Stop() error

func (*YouChain) StopMining added in v0.9.6

func (you *YouChain) StopMining() error

func (*YouChain) TxPool

func (you *YouChain) TxPool() *core.TxPool

func (*YouChain) UseValKey

func (you *YouChain) UseValKey(addr common.Address, password string, keep bool) error

func (*YouChain) YouVersion

func (you *YouChain) YouVersion() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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