本文整理匯總了Golang中github.com/ethereum/go-ethereum/eth.Ethereum.Miner方法的典型用法代碼示例。如果您正苦於以下問題:Golang Ethereum.Miner方法的具體用法?Golang Ethereum.Miner怎麽用?Golang Ethereum.Miner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ethereum/go-ethereum/eth.Ethereum
的用法示例。
在下文中一共展示了Ethereum.Miner方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: New
// New creates an XEth that uses the given frontend.
// If a nil Frontend is provided, a default frontend which
// confirms all transactions will be used.
func New(ethereum *eth.Ethereum, frontend Frontend) *XEth {
xeth := &XEth{
backend: ethereum,
frontend: frontend,
quit: make(chan struct{}),
filterManager: filter.NewFilterManager(ethereum.EventMux()),
logQueue: make(map[int]*logQueue),
blockQueue: make(map[int]*hashQueue),
transactionQueue: make(map[int]*hashQueue),
messages: make(map[int]*whisperFilter),
agent: miner.NewRemoteAgent(),
}
if ethereum.Whisper() != nil {
xeth.whisper = NewWhisper(ethereum.Whisper())
}
ethereum.Miner().Register(xeth.agent)
if frontend == nil {
xeth.frontend = dummyFrontend{}
}
xeth.state = NewState(xeth, xeth.backend.ChainManager().TransState())
go xeth.start()
go xeth.filterManager.Start()
return xeth
}
示例2: New
// New creates an XEth that uses the given frontend.
// If a nil Frontend is provided, a default frontend which
// confirms all transactions will be used.
func New(eth *eth.Ethereum, frontend Frontend) *XEth {
xeth := &XEth{
backend: eth,
frontend: frontend,
whisper: NewWhisper(eth.Whisper()),
quit: make(chan struct{}),
filterManager: filter.NewFilterManager(eth.EventMux()),
logs: make(map[int]*logFilter),
messages: make(map[int]*whisperFilter),
agent: miner.NewRemoteAgent(),
}
eth.Miner().Register(xeth.agent)
if frontend == nil {
xeth.frontend = dummyFrontend{}
}
xeth.state = NewState(xeth, xeth.backend.ChainManager().TransState())
go xeth.start()
go xeth.filterManager.Start()
return xeth
}
示例3: New
// New creates a new Ether APIs instance, connects with it to the Ethereum network
// via an embedded Geth instance and attaches an RPC in-process endpoint to it.
func New(datadir string, network geth.EthereumNetwork, address common.Address) (*EtherAPIs, error) {
// Create a Geth instance and boot it up
client, err := geth.New(datadir, network)
if err != nil {
return nil, err
}
if err := client.Start(); err != nil {
return nil, err
}
// Retrieve the underlying ethereum service and attach global RPC interface
var ethereum *eth.Ethereum
if err := client.Stack().Service(ðereum); err != nil {
return nil, err
}
api, err := client.Attach()
if err != nil {
return nil, err
}
// Assemble an interface around the consensus contract
contract, err := contract.New(ethereum.ChainDb(), ethereum.EventMux(), ethereum.BlockChain(), ethereum.Miner().PendingState)
if err != nil {
return nil, err
}
// Assemble and return the Ether APIs instance
return &EtherAPIs{
client: client,
ethereum: ethereum,
eventmux: client.Stack().EventMux(),
rpcapi: api,
contract: contract,
}, nil
}