forked from cerc-io/plugeth
cmd, common, console, eth, release: drop redundant "full"s
This commit is contained in:
parent
1e50f5dd28
commit
96dc42d99c
@ -328,7 +328,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||||||
}
|
}
|
||||||
// Start auxiliary services if enabled
|
// Start auxiliary services if enabled
|
||||||
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
|
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
|
||||||
var ethereum *eth.FullNodeService
|
var ethereum *eth.Ethereum
|
||||||
if err := stack.Service(ðereum); err != nil {
|
if err := stack.Service(ðereum); err != nil {
|
||||||
utils.Fatalf("ethereum service not running: %v", err)
|
utils.Fatalf("ethereum service not running: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ func MakeSystemNode(keydir string, privkey string, test *tests.BlockTest) (*node
|
|||||||
// RunTest executes the specified test against an already pre-configured protocol
|
// RunTest executes the specified test against an already pre-configured protocol
|
||||||
// stack to ensure basic checks pass before running RPC tests.
|
// stack to ensure basic checks pass before running RPC tests.
|
||||||
func RunTest(stack *node.Node, test *tests.BlockTest) error {
|
func RunTest(stack *node.Node, test *tests.BlockTest) error {
|
||||||
var ethereum *eth.FullNodeService
|
var ethereum *eth.Ethereum
|
||||||
stack.Service(ðereum)
|
stack.Service(ðereum)
|
||||||
blockchain := ethereum.BlockChain()
|
blockchain := ethereum.BlockChain()
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ const (
|
|||||||
|
|
||||||
type testFrontend struct {
|
type testFrontend struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
ethereum *eth.FullNodeService
|
ethereum *eth.Ethereum
|
||||||
xeth *xe.XEth
|
xeth *xe.XEth
|
||||||
wait chan *big.Int
|
wait chan *big.Int
|
||||||
lastConfirm string
|
lastConfirm string
|
||||||
@ -123,7 +123,7 @@ func (self *testFrontend) ConfirmTransaction(tx string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEth(t *testing.T) (ethereum *eth.FullNodeService, err error) {
|
func testEth(t *testing.T) (ethereum *eth.Ethereum, err error) {
|
||||||
|
|
||||||
tmp, err := ioutil.TempDir("", "natspec-test")
|
tmp, err := ioutil.TempDir("", "natspec-test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -76,7 +76,7 @@ func (p *hookedPrompter) SetWordCompleter(completer WordCompleter) {}
|
|||||||
type tester struct {
|
type tester struct {
|
||||||
workspace string
|
workspace string
|
||||||
stack *node.Node
|
stack *node.Node
|
||||||
ethereum *eth.FullNodeService
|
ethereum *eth.Ethereum
|
||||||
console *Console
|
console *Console
|
||||||
input *hookedPrompter
|
input *hookedPrompter
|
||||||
output *bytes.Buffer
|
output *bytes.Buffer
|
||||||
@ -134,7 +134,7 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
|
|||||||
t.Fatalf("failed to create JavaScript console: %v", err)
|
t.Fatalf("failed to create JavaScript console: %v", err)
|
||||||
}
|
}
|
||||||
// Create the final tester and return
|
// Create the final tester and return
|
||||||
var ethereum *eth.FullNodeService
|
var ethereum *eth.Ethereum
|
||||||
stack.Service(ðereum)
|
stack.Service(ðereum)
|
||||||
|
|
||||||
return &tester{
|
return &tester{
|
||||||
|
78
eth/api.go
78
eth/api.go
@ -40,41 +40,41 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PublicFullEthereumAPI provides an API to access Ethereum full node-related
|
// PublicEthereumAPI provides an API to access Ethereum full node-related
|
||||||
// information.
|
// information.
|
||||||
type PublicFullEthereumAPI struct {
|
type PublicEthereumAPI struct {
|
||||||
e *FullNodeService
|
e *Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPublicFullEthereumAPI creates a new Etheruem protocol API for full nodes.
|
// NewPublicEthereumAPI creates a new Etheruem protocol API for full nodes.
|
||||||
func NewPublicFullEthereumAPI(e *FullNodeService) *PublicFullEthereumAPI {
|
func NewPublicEthereumAPI(e *Ethereum) *PublicEthereumAPI {
|
||||||
return &PublicFullEthereumAPI{e}
|
return &PublicEthereumAPI{e}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Etherbase is the address that mining rewards will be send to
|
// Etherbase is the address that mining rewards will be send to
|
||||||
func (s *PublicFullEthereumAPI) Etherbase() (common.Address, error) {
|
func (s *PublicEthereumAPI) Etherbase() (common.Address, error) {
|
||||||
return s.e.Etherbase()
|
return s.e.Etherbase()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coinbase is the address that mining rewards will be send to (alias for Etherbase)
|
// Coinbase is the address that mining rewards will be send to (alias for Etherbase)
|
||||||
func (s *PublicFullEthereumAPI) Coinbase() (common.Address, error) {
|
func (s *PublicEthereumAPI) Coinbase() (common.Address, error) {
|
||||||
return s.Etherbase()
|
return s.Etherbase()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hashrate returns the POW hashrate
|
// Hashrate returns the POW hashrate
|
||||||
func (s *PublicFullEthereumAPI) Hashrate() *rpc.HexNumber {
|
func (s *PublicEthereumAPI) Hashrate() *rpc.HexNumber {
|
||||||
return rpc.NewHexNumber(s.e.Miner().HashRate())
|
return rpc.NewHexNumber(s.e.Miner().HashRate())
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublicMinerAPI provides an API to control the miner.
|
// PublicMinerAPI provides an API to control the miner.
|
||||||
// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
|
// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
|
||||||
type PublicMinerAPI struct {
|
type PublicMinerAPI struct {
|
||||||
e *FullNodeService
|
e *Ethereum
|
||||||
agent *miner.RemoteAgent
|
agent *miner.RemoteAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPublicMinerAPI create a new PublicMinerAPI instance.
|
// NewPublicMinerAPI create a new PublicMinerAPI instance.
|
||||||
func NewPublicMinerAPI(e *FullNodeService) *PublicMinerAPI {
|
func NewPublicMinerAPI(e *Ethereum) *PublicMinerAPI {
|
||||||
agent := miner.NewRemoteAgent()
|
agent := miner.NewRemoteAgent()
|
||||||
e.Miner().Register(agent)
|
e.Miner().Register(agent)
|
||||||
|
|
||||||
@ -120,11 +120,11 @@ func (s *PublicMinerAPI) SubmitHashrate(hashrate rpc.HexNumber, id common.Hash)
|
|||||||
// PrivateMinerAPI provides private RPC methods to control the miner.
|
// PrivateMinerAPI provides private RPC methods to control the miner.
|
||||||
// These methods can be abused by external users and must be considered insecure for use by untrusted users.
|
// These methods can be abused by external users and must be considered insecure for use by untrusted users.
|
||||||
type PrivateMinerAPI struct {
|
type PrivateMinerAPI struct {
|
||||||
e *FullNodeService
|
e *Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPrivateMinerAPI create a new RPC service which controls the miner of this node.
|
// NewPrivateMinerAPI create a new RPC service which controls the miner of this node.
|
||||||
func NewPrivateMinerAPI(e *FullNodeService) *PrivateMinerAPI {
|
func NewPrivateMinerAPI(e *Ethereum) *PrivateMinerAPI {
|
||||||
return &PrivateMinerAPI{e: e}
|
return &PrivateMinerAPI{e: e}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,20 +191,20 @@ func (s *PrivateMinerAPI) MakeDAG(blockNr rpc.BlockNumber) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrivateFullAdminAPI is the collection of Etheruem full node-related APIs
|
// PrivateAdminAPI is the collection of Etheruem full node-related APIs
|
||||||
// exposed over the private admin endpoint.
|
// exposed over the private admin endpoint.
|
||||||
type PrivateFullAdminAPI struct {
|
type PrivateAdminAPI struct {
|
||||||
eth *FullNodeService
|
eth *Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPrivateAdminAPI creates a new API definition for the full node private
|
// NewPrivateAdminAPI creates a new API definition for the full node private
|
||||||
// admin methods of the Ethereum service.
|
// admin methods of the Ethereum service.
|
||||||
func NewPrivateFullAdminAPI(eth *FullNodeService) *PrivateFullAdminAPI {
|
func NewPrivateAdminAPI(eth *Ethereum) *PrivateAdminAPI {
|
||||||
return &PrivateFullAdminAPI{eth: eth}
|
return &PrivateAdminAPI{eth: eth}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportChain exports the current blockchain into a local file.
|
// ExportChain exports the current blockchain into a local file.
|
||||||
func (api *PrivateFullAdminAPI) ExportChain(file string) (bool, error) {
|
func (api *PrivateAdminAPI) ExportChain(file string) (bool, error) {
|
||||||
// Make sure we can create the file to export into
|
// Make sure we can create the file to export into
|
||||||
out, err := os.OpenFile(file, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
|
out, err := os.OpenFile(file, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -230,7 +230,7 @@ func hasAllBlocks(chain *core.BlockChain, bs []*types.Block) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ImportChain imports a blockchain from a local file.
|
// ImportChain imports a blockchain from a local file.
|
||||||
func (api *PrivateFullAdminAPI) ImportChain(file string) (bool, error) {
|
func (api *PrivateAdminAPI) ImportChain(file string) (bool, error) {
|
||||||
// Make sure the can access the file to import
|
// Make sure the can access the file to import
|
||||||
in, err := os.Open(file)
|
in, err := os.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -271,20 +271,20 @@ func (api *PrivateFullAdminAPI) ImportChain(file string) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublicFullDebugAPI is the collection of Etheruem full node APIs exposed
|
// PublicDebugAPI is the collection of Etheruem full node APIs exposed
|
||||||
// over the public debugging endpoint.
|
// over the public debugging endpoint.
|
||||||
type PublicFullDebugAPI struct {
|
type PublicDebugAPI struct {
|
||||||
eth *FullNodeService
|
eth *Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPublicFullDebugAPI creates a new API definition for the full node-
|
// NewPublicDebugAPI creates a new API definition for the full node-
|
||||||
// related public debug methods of the Ethereum service.
|
// related public debug methods of the Ethereum service.
|
||||||
func NewPublicFullDebugAPI(eth *FullNodeService) *PublicFullDebugAPI {
|
func NewPublicDebugAPI(eth *Ethereum) *PublicDebugAPI {
|
||||||
return &PublicFullDebugAPI{eth: eth}
|
return &PublicDebugAPI{eth: eth}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DumpBlock retrieves the entire state of the database at a given block.
|
// DumpBlock retrieves the entire state of the database at a given block.
|
||||||
func (api *PublicFullDebugAPI) DumpBlock(number uint64) (state.World, error) {
|
func (api *PublicDebugAPI) DumpBlock(number uint64) (state.World, error) {
|
||||||
block := api.eth.BlockChain().GetBlockByNumber(number)
|
block := api.eth.BlockChain().GetBlockByNumber(number)
|
||||||
if block == nil {
|
if block == nil {
|
||||||
return state.World{}, fmt.Errorf("block #%d not found", number)
|
return state.World{}, fmt.Errorf("block #%d not found", number)
|
||||||
@ -296,17 +296,17 @@ func (api *PublicFullDebugAPI) DumpBlock(number uint64) (state.World, error) {
|
|||||||
return stateDb.RawDump(), nil
|
return stateDb.RawDump(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrivateFullDebugAPI is the collection of Etheruem full node APIs exposed over
|
// PrivateDebugAPI is the collection of Etheruem full node APIs exposed over
|
||||||
// the private debugging endpoint.
|
// the private debugging endpoint.
|
||||||
type PrivateFullDebugAPI struct {
|
type PrivateDebugAPI struct {
|
||||||
config *core.ChainConfig
|
config *core.ChainConfig
|
||||||
eth *FullNodeService
|
eth *Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPrivateFullDebugAPI creates a new API definition for the full node-related
|
// NewPrivateDebugAPI creates a new API definition for the full node-related
|
||||||
// private debug methods of the Ethereum service.
|
// private debug methods of the Ethereum service.
|
||||||
func NewPrivateFullDebugAPI(config *core.ChainConfig, eth *FullNodeService) *PrivateFullDebugAPI {
|
func NewPrivateDebugAPI(config *core.ChainConfig, eth *Ethereum) *PrivateDebugAPI {
|
||||||
return &PrivateFullDebugAPI{config: config, eth: eth}
|
return &PrivateDebugAPI{config: config, eth: eth}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockTraceResult is the returned value when replaying a block to check for
|
// BlockTraceResult is the returned value when replaying a block to check for
|
||||||
@ -319,7 +319,7 @@ type BlockTraceResult struct {
|
|||||||
|
|
||||||
// TraceBlock processes the given block's RLP but does not import the block in to
|
// TraceBlock processes the given block's RLP but does not import the block in to
|
||||||
// the chain.
|
// the chain.
|
||||||
func (api *PrivateFullDebugAPI) TraceBlock(blockRlp []byte, config *vm.Config) BlockTraceResult {
|
func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config *vm.Config) BlockTraceResult {
|
||||||
var block types.Block
|
var block types.Block
|
||||||
err := rlp.Decode(bytes.NewReader(blockRlp), &block)
|
err := rlp.Decode(bytes.NewReader(blockRlp), &block)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -336,7 +336,7 @@ func (api *PrivateFullDebugAPI) TraceBlock(blockRlp []byte, config *vm.Config) B
|
|||||||
|
|
||||||
// TraceBlockFromFile loads the block's RLP from the given file name and attempts to
|
// TraceBlockFromFile loads the block's RLP from the given file name and attempts to
|
||||||
// process it but does not import the block in to the chain.
|
// process it but does not import the block in to the chain.
|
||||||
func (api *PrivateFullDebugAPI) TraceBlockFromFile(file string, config *vm.Config) BlockTraceResult {
|
func (api *PrivateDebugAPI) TraceBlockFromFile(file string, config *vm.Config) BlockTraceResult {
|
||||||
blockRlp, err := ioutil.ReadFile(file)
|
blockRlp, err := ioutil.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BlockTraceResult{Error: fmt.Sprintf("could not read file: %v", err)}
|
return BlockTraceResult{Error: fmt.Sprintf("could not read file: %v", err)}
|
||||||
@ -345,7 +345,7 @@ func (api *PrivateFullDebugAPI) TraceBlockFromFile(file string, config *vm.Confi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TraceBlockByNumber processes the block by canonical block number.
|
// TraceBlockByNumber processes the block by canonical block number.
|
||||||
func (api *PrivateFullDebugAPI) TraceBlockByNumber(number uint64, config *vm.Config) BlockTraceResult {
|
func (api *PrivateDebugAPI) TraceBlockByNumber(number uint64, config *vm.Config) BlockTraceResult {
|
||||||
// Fetch the block that we aim to reprocess
|
// Fetch the block that we aim to reprocess
|
||||||
block := api.eth.BlockChain().GetBlockByNumber(number)
|
block := api.eth.BlockChain().GetBlockByNumber(number)
|
||||||
if block == nil {
|
if block == nil {
|
||||||
@ -361,7 +361,7 @@ func (api *PrivateFullDebugAPI) TraceBlockByNumber(number uint64, config *vm.Con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TraceBlockByHash processes the block by hash.
|
// TraceBlockByHash processes the block by hash.
|
||||||
func (api *PrivateFullDebugAPI) TraceBlockByHash(hash common.Hash, config *vm.Config) BlockTraceResult {
|
func (api *PrivateDebugAPI) TraceBlockByHash(hash common.Hash, config *vm.Config) BlockTraceResult {
|
||||||
// Fetch the block that we aim to reprocess
|
// Fetch the block that we aim to reprocess
|
||||||
block := api.eth.BlockChain().GetBlockByHash(hash)
|
block := api.eth.BlockChain().GetBlockByHash(hash)
|
||||||
if block == nil {
|
if block == nil {
|
||||||
@ -389,7 +389,7 @@ func (t *TraceCollector) AddStructLog(slog vm.StructLog) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// traceBlock processes the given block but does not save the state.
|
// traceBlock processes the given block but does not save the state.
|
||||||
func (api *PrivateFullDebugAPI) traceBlock(block *types.Block, config *vm.Config) (bool, []vm.StructLog, error) {
|
func (api *PrivateDebugAPI) traceBlock(block *types.Block, config *vm.Config) (bool, []vm.StructLog, error) {
|
||||||
// Validate and reprocess the block
|
// Validate and reprocess the block
|
||||||
var (
|
var (
|
||||||
blockchain = api.eth.BlockChain()
|
blockchain = api.eth.BlockChain()
|
||||||
@ -452,7 +452,7 @@ func formatError(err error) string {
|
|||||||
|
|
||||||
// TraceTransaction returns the structured logs created during the execution of EVM
|
// TraceTransaction returns the structured logs created during the execution of EVM
|
||||||
// and returns them as a JSON object.
|
// and returns them as a JSON object.
|
||||||
func (api *PrivateFullDebugAPI) TraceTransaction(txHash common.Hash, logger *vm.LogConfig) (*ethapi.ExecutionResult, error) {
|
func (api *PrivateDebugAPI) TraceTransaction(txHash common.Hash, logger *vm.LogConfig) (*ethapi.ExecutionResult, error) {
|
||||||
if logger == nil {
|
if logger == nil {
|
||||||
logger = new(vm.LogConfig)
|
logger = new(vm.LogConfig)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ import (
|
|||||||
|
|
||||||
// EthApiBackend implements ethapi.Backend for full nodes
|
// EthApiBackend implements ethapi.Backend for full nodes
|
||||||
type EthApiBackend struct {
|
type EthApiBackend struct {
|
||||||
eth *FullNodeService
|
eth *Ethereum
|
||||||
gpo *gasprice.GasPriceOracle
|
gpo *gasprice.GasPriceOracle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ type Config struct {
|
|||||||
TestGenesisState ethdb.Database // Genesis state to seed the database with (testing only!)
|
TestGenesisState ethdb.Database // Genesis state to seed the database with (testing only!)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullNodeService implements the Ethereum full node service.
|
// Ethereum implements the Ethereum full node service.
|
||||||
type FullNodeService struct {
|
type Ethereum struct {
|
||||||
chainConfig *core.ChainConfig
|
chainConfig *core.ChainConfig
|
||||||
// Channel for shutting down the service
|
// Channel for shutting down the service
|
||||||
shutdownChan chan bool // Channel for shutting down the ethereum
|
shutdownChan chan bool // Channel for shutting down the ethereum
|
||||||
@ -140,9 +140,9 @@ type FullNodeService struct {
|
|||||||
netRPCService *ethapi.PublicNetAPI
|
netRPCService *ethapi.PublicNetAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new FullNodeService object (including the
|
// New creates a new Ethereum object (including the
|
||||||
// initialisation of the common Ethereum object)
|
// initialisation of the common Ethereum object)
|
||||||
func New(ctx *node.ServiceContext, config *Config) (*FullNodeService, error) {
|
func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
chainDb, dappDb, err := CreateDBs(ctx, config)
|
chainDb, dappDb, err := CreateDBs(ctx, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -156,7 +156,7 @@ func New(ctx *node.ServiceContext, config *Config) (*FullNodeService, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
eth := &FullNodeService{
|
eth := &Ethereum{
|
||||||
chainDb: chainDb,
|
chainDb: chainDb,
|
||||||
dappDb: dappDb,
|
dappDb: dappDb,
|
||||||
eventMux: ctx.EventMux,
|
eventMux: ctx.EventMux,
|
||||||
@ -303,12 +303,12 @@ func CreatePoW(config *Config) (*ethash.Ethash, error) {
|
|||||||
|
|
||||||
// APIs returns the collection of RPC services the ethereum package offers.
|
// APIs returns the collection of RPC services the ethereum package offers.
|
||||||
// NOTE, some of these services probably need to be moved to somewhere else.
|
// NOTE, some of these services probably need to be moved to somewhere else.
|
||||||
func (s *FullNodeService) APIs() []rpc.API {
|
func (s *Ethereum) APIs() []rpc.API {
|
||||||
return append(ethapi.GetAPIs(s.apiBackend, &s.solcPath, &s.solc), []rpc.API{
|
return append(ethapi.GetAPIs(s.apiBackend, &s.solcPath, &s.solc), []rpc.API{
|
||||||
{
|
{
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicFullEthereumAPI(s),
|
Service: NewPublicEthereumAPI(s),
|
||||||
Public: true,
|
Public: true,
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
@ -333,16 +333,16 @@ func (s *FullNodeService) APIs() []rpc.API {
|
|||||||
}, {
|
}, {
|
||||||
Namespace: "admin",
|
Namespace: "admin",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPrivateFullAdminAPI(s),
|
Service: NewPrivateAdminAPI(s),
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicFullDebugAPI(s),
|
Service: NewPublicDebugAPI(s),
|
||||||
Public: true,
|
Public: true,
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPrivateFullDebugAPI(s.chainConfig, s),
|
Service: NewPrivateDebugAPI(s.chainConfig, s),
|
||||||
}, {
|
}, {
|
||||||
Namespace: "net",
|
Namespace: "net",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
@ -356,11 +356,11 @@ func (s *FullNodeService) APIs() []rpc.API {
|
|||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeService) ResetWithGenesisBlock(gb *types.Block) {
|
func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {
|
||||||
s.blockchain.ResetWithGenesisBlock(gb)
|
s.blockchain.ResetWithGenesisBlock(gb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeService) Etherbase() (eb common.Address, err error) {
|
func (s *Ethereum) Etherbase() (eb common.Address, err error) {
|
||||||
eb = s.etherbase
|
eb = s.etherbase
|
||||||
if (eb == common.Address{}) {
|
if (eb == common.Address{}) {
|
||||||
firstAccount, err := s.AccountManager().AccountByIndex(0)
|
firstAccount, err := s.AccountManager().AccountByIndex(0)
|
||||||
@ -373,36 +373,36 @@ func (s *FullNodeService) Etherbase() (eb common.Address, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set in js console via admin interface or wrapper from cli flags
|
// set in js console via admin interface or wrapper from cli flags
|
||||||
func (self *FullNodeService) SetEtherbase(etherbase common.Address) {
|
func (self *Ethereum) SetEtherbase(etherbase common.Address) {
|
||||||
self.etherbase = etherbase
|
self.etherbase = etherbase
|
||||||
self.miner.SetEtherbase(etherbase)
|
self.miner.SetEtherbase(etherbase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeService) StopMining() { s.miner.Stop() }
|
func (s *Ethereum) StopMining() { s.miner.Stop() }
|
||||||
func (s *FullNodeService) IsMining() bool { return s.miner.Mining() }
|
func (s *Ethereum) IsMining() bool { return s.miner.Mining() }
|
||||||
func (s *FullNodeService) Miner() *miner.Miner { return s.miner }
|
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
||||||
|
|
||||||
func (s *FullNodeService) AccountManager() *accounts.Manager { return s.accountManager }
|
func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
|
||||||
func (s *FullNodeService) BlockChain() *core.BlockChain { return s.blockchain }
|
func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
|
||||||
func (s *FullNodeService) TxPool() *core.TxPool { return s.txPool }
|
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
|
||||||
func (s *FullNodeService) EventMux() *event.TypeMux { return s.eventMux }
|
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
|
||||||
func (s *FullNodeService) Pow() *ethash.Ethash { return s.pow }
|
func (s *Ethereum) Pow() *ethash.Ethash { return s.pow }
|
||||||
func (s *FullNodeService) ChainDb() ethdb.Database { return s.chainDb }
|
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
|
||||||
func (s *FullNodeService) DappDb() ethdb.Database { return s.dappDb }
|
func (s *Ethereum) DappDb() ethdb.Database { return s.dappDb }
|
||||||
func (s *FullNodeService) IsListening() bool { return true } // Always listening
|
func (s *Ethereum) IsListening() bool { return true } // Always listening
|
||||||
func (s *FullNodeService) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
|
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
|
||||||
func (s *FullNodeService) NetVersion() int { return s.netVersionId }
|
func (s *Ethereum) NetVersion() int { return s.netVersionId }
|
||||||
func (s *FullNodeService) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
||||||
|
|
||||||
// Protocols implements node.Service, returning all the currently configured
|
// Protocols implements node.Service, returning all the currently configured
|
||||||
// network protocols to start.
|
// network protocols to start.
|
||||||
func (s *FullNodeService) Protocols() []p2p.Protocol {
|
func (s *Ethereum) Protocols() []p2p.Protocol {
|
||||||
return s.protocolManager.SubProtocols
|
return s.protocolManager.SubProtocols
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start implements node.Service, starting all internal goroutines needed by the
|
// Start implements node.Service, starting all internal goroutines needed by the
|
||||||
// FullNodeService protocol implementation.
|
// Ethereum protocol implementation.
|
||||||
func (s *FullNodeService) Start(srvr *p2p.Server) error {
|
func (s *Ethereum) Start(srvr *p2p.Server) error {
|
||||||
s.netRPCService = ethapi.NewPublicNetAPI(srvr, s.NetVersion())
|
s.netRPCService = ethapi.NewPublicNetAPI(srvr, s.NetVersion())
|
||||||
if s.AutoDAG {
|
if s.AutoDAG {
|
||||||
s.StartAutoDAG()
|
s.StartAutoDAG()
|
||||||
@ -413,7 +413,7 @@ func (s *FullNodeService) Start(srvr *p2p.Server) error {
|
|||||||
|
|
||||||
// Stop implements node.Service, terminating all internal goroutines used by the
|
// Stop implements node.Service, terminating all internal goroutines used by the
|
||||||
// Ethereum protocol.
|
// Ethereum protocol.
|
||||||
func (s *FullNodeService) Stop() error {
|
func (s *Ethereum) Stop() error {
|
||||||
if s.stopDbUpgrade != nil {
|
if s.stopDbUpgrade != nil {
|
||||||
s.stopDbUpgrade()
|
s.stopDbUpgrade()
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ func (s *FullNodeService) Stop() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function will wait for a shutdown and resumes main thread execution
|
// This function will wait for a shutdown and resumes main thread execution
|
||||||
func (s *FullNodeService) WaitForShutdown() {
|
func (s *Ethereum) WaitForShutdown() {
|
||||||
<-s.shutdownChan
|
<-s.shutdownChan
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ func (s *FullNodeService) WaitForShutdown() {
|
|||||||
// stop any number of times.
|
// stop any number of times.
|
||||||
// For any more sophisticated pattern of DAG generation, use CLI subcommand
|
// For any more sophisticated pattern of DAG generation, use CLI subcommand
|
||||||
// makedag
|
// makedag
|
||||||
func (self *FullNodeService) StartAutoDAG() {
|
func (self *Ethereum) StartAutoDAG() {
|
||||||
if self.autodagquit != nil {
|
if self.autodagquit != nil {
|
||||||
return // already started
|
return // already started
|
||||||
}
|
}
|
||||||
@ -492,7 +492,7 @@ func (self *FullNodeService) StartAutoDAG() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stopAutoDAG stops automatic DAG pregeneration by quitting the loop
|
// stopAutoDAG stops automatic DAG pregeneration by quitting the loop
|
||||||
func (self *FullNodeService) StopAutoDAG() {
|
func (self *Ethereum) StopAutoDAG() {
|
||||||
if self.autodagquit != nil {
|
if self.autodagquit != nil {
|
||||||
close(self.autodagquit)
|
close(self.autodagquit)
|
||||||
self.autodagquit = nil
|
self.autodagquit = nil
|
||||||
@ -502,7 +502,7 @@ func (self *FullNodeService) StopAutoDAG() {
|
|||||||
|
|
||||||
// HTTPClient returns the light http client used for fetching offchain docs
|
// HTTPClient returns the light http client used for fetching offchain docs
|
||||||
// (natspec, source for verification)
|
// (natspec, source for verification)
|
||||||
func (self *FullNodeService) HTTPClient() *httpclient.HTTPClient {
|
func (self *Ethereum) HTTPClient() *httpclient.HTTPClient {
|
||||||
return self.httpclient
|
return self.httpclient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ type ContractBackend struct {
|
|||||||
|
|
||||||
// NewContractBackend creates a new native contract backend using an existing
|
// NewContractBackend creates a new native contract backend using an existing
|
||||||
// Etheruem object.
|
// Etheruem object.
|
||||||
func NewContractBackend(eth *FullNodeService) *ContractBackend {
|
func NewContractBackend(eth *Ethereum) *ContractBackend {
|
||||||
return &ContractBackend{
|
return &ContractBackend{
|
||||||
eapi: ethapi.NewPublicEthereumAPI(eth.apiBackend, nil, nil),
|
eapi: ethapi.NewPublicEthereumAPI(eth.apiBackend, nil, nil),
|
||||||
bcapi: ethapi.NewPublicBlockChainAPI(eth.apiBackend),
|
bcapi: ethapi.NewPublicBlockChainAPI(eth.apiBackend),
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
const disabledInfo = "Set GO_OPENCL and re-build to enable."
|
const disabledInfo = "Set GO_OPENCL and re-build to enable."
|
||||||
|
|
||||||
func (s *FullNodeService) StartMining(threads int, gpus string) error {
|
func (s *Ethereum) StartMining(threads int, gpus string) error {
|
||||||
eb, err := s.Etherbase()
|
eb, err := s.Etherbase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("Cannot start mining without etherbase address: %v", err)
|
err = fmt.Errorf("Cannot start mining without etherbase address: %v", err)
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/miner"
|
"github.com/ethereum/go-ethereum/miner"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *FullNodeService) StartMining(threads int, gpus string) error {
|
func (s *Ethereum) StartMining(threads int, gpus string) error {
|
||||||
eb, err := s.Etherbase()
|
eb, err := s.Etherbase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("Cannot start mining without etherbase address: %v", err)
|
err = fmt.Errorf("Cannot start mining without etherbase address: %v", err)
|
||||||
|
@ -58,7 +58,7 @@ type ReleaseService struct {
|
|||||||
// releases and notify the user of such.
|
// releases and notify the user of such.
|
||||||
func NewReleaseService(ctx *node.ServiceContext, config Config) (node.Service, error) {
|
func NewReleaseService(ctx *node.ServiceContext, config Config) (node.Service, error) {
|
||||||
// Retrieve the Ethereum service dependency to access the blockchain
|
// Retrieve the Ethereum service dependency to access the blockchain
|
||||||
var ethereum *eth.FullNodeService
|
var ethereum *eth.Ethereum
|
||||||
if err := ctx.Service(ðereum); err != nil {
|
if err := ctx.Service(ðereum); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user