mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
wip, updates
This commit is contained in:
parent
0c8f2376fa
commit
1220efc349
13 changed files with 40 additions and 54 deletions
|
|
@ -591,7 +591,7 @@ func testExternalUI(api *core.SignerAPI) {
|
||||||
checkErr("SignTransaction", err)
|
checkErr("SignTransaction", err)
|
||||||
_, err = api.Sign(ctx, common.MixedcaseAddress{}, common.Hex2Bytes("01020304"))
|
_, err = api.Sign(ctx, common.MixedcaseAddress{}, common.Hex2Bytes("01020304"))
|
||||||
checkErr("Sign", err)
|
checkErr("Sign", err)
|
||||||
_, err = api.List(ctx)
|
_, err = api.ListAccounts(ctx)
|
||||||
checkErr("List", err)
|
checkErr("List", err)
|
||||||
_, err = api.New(ctx)
|
_, err = api.New(ctx)
|
||||||
checkErr("New", err)
|
checkErr("New", err)
|
||||||
|
|
|
||||||
|
|
@ -152,9 +152,7 @@ func enableWhisper(ctx *cli.Context) bool {
|
||||||
|
|
||||||
func makeFullNode(ctx *cli.Context) *node.Node {
|
func makeFullNode(ctx *cli.Context) *node.Node {
|
||||||
stack, cfg := makeConfigNode(ctx)
|
stack, cfg := makeConfigNode(ctx)
|
||||||
|
|
||||||
utils.RegisterEthService(stack, &cfg.Eth)
|
utils.RegisterEthService(stack, &cfg.Eth)
|
||||||
|
|
||||||
if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
|
if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
|
||||||
utils.RegisterDashboardService(stack, &cfg.Dashboard, gitCommit)
|
utils.RegisterDashboardService(stack, &cfg.Dashboard, gitCommit)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ var (
|
||||||
utils.EthashDatasetDirFlag,
|
utils.EthashDatasetDirFlag,
|
||||||
utils.EthashDatasetsInMemoryFlag,
|
utils.EthashDatasetsInMemoryFlag,
|
||||||
utils.EthashDatasetsOnDiskFlag,
|
utils.EthashDatasetsOnDiskFlag,
|
||||||
|
utils.ExternalSignerFlag,
|
||||||
utils.TxPoolNoLocalsFlag,
|
utils.TxPoolNoLocalsFlag,
|
||||||
utils.TxPoolJournalFlag,
|
utils.TxPoolJournalFlag,
|
||||||
utils.TxPoolRejournalFlag,
|
utils.TxPoolRejournalFlag,
|
||||||
|
|
@ -258,12 +259,8 @@ func geth(ctx *cli.Context) error {
|
||||||
func startNode(ctx *cli.Context, stack *node.Node) {
|
func startNode(ctx *cli.Context, stack *node.Node) {
|
||||||
debug.Memsize.Add("node", stack)
|
debug.Memsize.Add("node", stack)
|
||||||
|
|
||||||
// Start up the node itself
|
|
||||||
utils.StartNode(stack)
|
|
||||||
|
|
||||||
// Start account management
|
// Start account management
|
||||||
if ctx.IsSet(utils.ExternalSignerFlag.Name){
|
if extEndpoint := ctx.GlobalString(utils.ExternalSignerFlag.Name); extEndpoint != ""{
|
||||||
extEndpoint := ctx.GlobalString(utils.ExternalSignerFlag.Name)
|
|
||||||
extApi, err := ethapi.NewExternalSigner(extEndpoint)
|
extApi, err := ethapi.NewExternalSigner(extEndpoint)
|
||||||
if err != nil{
|
if err != nil{
|
||||||
utils.Fatalf("Could not connect to external signer at %v: %v" , extEndpoint, err)
|
utils.Fatalf("Could not connect to external signer at %v: %v" , extEndpoint, err)
|
||||||
|
|
@ -271,6 +268,10 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
||||||
log.Info("External signer connected", "url", extEndpoint)
|
log.Info("External signer connected", "url", extEndpoint)
|
||||||
stack.SetExternalAPI(extApi)
|
stack.SetExternalAPI(extApi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start up the node itself
|
||||||
|
utils.StartNode(stack)
|
||||||
|
|
||||||
// Start auxiliary services if enabled
|
// Start auxiliary services if enabled
|
||||||
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) {
|
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) {
|
||||||
// Mining only makes sense if a full Ethereum node is running
|
// Mining only makes sense if a full Ethereum node is running
|
||||||
|
|
|
||||||
|
|
@ -1121,7 +1121,7 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) {
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
|
err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
|
||||||
fullNode, err := eth.New(ctx, cfg)
|
fullNode, err := eth.New(ctx, cfg, stack.ExternalSignerAPI())
|
||||||
if fullNode != nil && cfg.LightServ > 0 {
|
if fullNode != nil && cfg.LightServ > 0 {
|
||||||
ls, _ := les.NewLesServer(fullNode, cfg)
|
ls, _ := les.NewLesServer(fullNode, cfg)
|
||||||
fullNode.AddLesServer(ls)
|
fullNode.AddLesServer(ls)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EthAPIBackend implements ethapi.Backend for full nodes
|
// EthAPIBackend implements ethapi.Backend for full nodes
|
||||||
|
|
@ -226,7 +227,7 @@ func (b *EthAPIBackend) ServiceFilter(ctx context.Context, session *bloombits.Ma
|
||||||
go session.Multiplex(bloomRetrievalBatch, bloomRetrievalWait, b.eth.bloomRequests)
|
go session.Multiplex(bloomRetrievalBatch, bloomRetrievalWait, b.eth.bloomRequests)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (b *EthAPIBackend) ExternalSigner() string {
|
func (b *EthAPIBackend) ExternalSigner() *ethapi.ExternalSignerAPI {
|
||||||
return b.eth.externalSigner
|
return b.eth.externalSigner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ type Ethereum struct {
|
||||||
|
|
||||||
eventMux *event.TypeMux
|
eventMux *event.TypeMux
|
||||||
engine consensus.Engine
|
engine consensus.Engine
|
||||||
externalSigner string
|
externalSigner *ethapi.ExternalSignerAPI
|
||||||
|
|
||||||
bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests
|
bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests
|
||||||
bloomIndexer *core.ChainIndexer // Bloom indexer operating during block imports
|
bloomIndexer *core.ChainIndexer // Bloom indexer operating during block imports
|
||||||
|
|
@ -100,7 +100,7 @@ func (s *Ethereum) AddLesServer(ls LesServer) {
|
||||||
|
|
||||||
// New creates a new Ethereum 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) (*Ethereum, error) {
|
func New(ctx *node.ServiceContext, config *Config, api *ethapi.ExternalSignerAPI) (*Ethereum, error) {
|
||||||
if config.SyncMode == downloader.LightSync {
|
if config.SyncMode == downloader.LightSync {
|
||||||
return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum")
|
return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum")
|
||||||
}
|
}
|
||||||
|
|
@ -119,6 +119,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
|
|
||||||
eth := &Ethereum{
|
eth := &Ethereum{
|
||||||
config: config,
|
config: config,
|
||||||
|
externalSigner: api,
|
||||||
chainDb: chainDb,
|
chainDb: chainDb,
|
||||||
chainConfig: chainConfig,
|
chainConfig: chainConfig,
|
||||||
eventMux: ctx.EventMux,
|
eventMux: ctx.EventMux,
|
||||||
|
|
@ -331,7 +332,6 @@ func (s *Ethereum) StartMining(local bool) error {
|
||||||
log.Error("Etherbase account unavailable locally", "err", err)
|
log.Error("Etherbase account unavailable locally", "err", err)
|
||||||
return fmt.Errorf("signer not configured: %v", err)
|
return fmt.Errorf("signer not configured: %v", err)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if local {
|
if local {
|
||||||
// If local (CPU) mining is started, we can disable the transaction rejection
|
// If local (CPU) mining is started, we can disable the transaction rejection
|
||||||
|
|
@ -348,16 +348,16 @@ func (s *Ethereum) StopMining() { s.miner.Stop() }
|
||||||
func (s *Ethereum) IsMining() bool { return s.miner.Mining() }
|
func (s *Ethereum) IsMining() bool { return s.miner.Mining() }
|
||||||
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
||||||
|
|
||||||
func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
|
func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
|
||||||
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
|
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
|
||||||
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
|
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
|
||||||
func (s *Ethereum) Engine() consensus.Engine { return s.engine }
|
func (s *Ethereum) Engine() consensus.Engine { return s.engine }
|
||||||
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
|
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
|
||||||
func (s *Ethereum) IsListening() bool { return true } // Always listening
|
func (s *Ethereum) IsListening() bool { return true } // Always listening
|
||||||
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
|
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
|
||||||
func (s *Ethereum) NetVersion() uint64 { return s.networkID }
|
func (s *Ethereum) NetVersion() uint64 { return s.networkID }
|
||||||
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
||||||
func (s *Ethereum) ExternalSigner() string { return s.externalSigner }
|
func (s *Ethereum) ExternalSigner() *ethapi.ExternalSignerAPI { return s.externalSigner }
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
||||||
|
|
@ -191,14 +191,7 @@ func NewPrivateAccountAPI(b Backend, nonceLock *AddrLocker) *PrivateAccountAPI {
|
||||||
p := &PrivateAccountAPI{
|
p := &PrivateAccountAPI{
|
||||||
nonceLock: nonceLock,
|
nonceLock: nonceLock,
|
||||||
b: b,
|
b: b,
|
||||||
}
|
extapi: b.ExternalSigner(),
|
||||||
if b.ExternalSigner() != "" {
|
|
||||||
extapi, err := NewExternalSigner(b.ExternalSigner())
|
|
||||||
if err == nil {
|
|
||||||
p.extapi = extapi
|
|
||||||
} else {
|
|
||||||
log.Error("Error initializing external signer", "url", b.ExternalSigner(), "error", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
@ -818,18 +811,7 @@ type PublicTransactionPoolAPI struct {
|
||||||
|
|
||||||
// NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.
|
// NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.
|
||||||
func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI {
|
func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI {
|
||||||
var (
|
return &PublicTransactionPoolAPI{b, nonceLock, b.ExternalSigner()}
|
||||||
extapi *ExternalSignerAPI
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
if b.ExternalSigner() != "" {
|
|
||||||
extapi, err = NewExternalSigner(b.ExternalSigner())
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Error initializing external signer", "url", b.ExternalSigner(), "error", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return &PublicTransactionPoolAPI{b, nonceLock, extapi}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.
|
// GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ type Backend interface {
|
||||||
SuggestPrice(ctx context.Context) (*big.Int, error)
|
SuggestPrice(ctx context.Context) (*big.Int, error)
|
||||||
ChainDb() ethdb.Database
|
ChainDb() ethdb.Database
|
||||||
EventMux() *event.TypeMux
|
EventMux() *event.TypeMux
|
||||||
ExternalSigner() string
|
ExternalSigner() *ExternalSignerAPI
|
||||||
|
|
||||||
// BlockChain API
|
// BlockChain API
|
||||||
SetHead(number uint64)
|
SetHead(number uint64)
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/light"
|
"github.com/ethereum/go-ethereum/light"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LesApiBackend struct {
|
type LesApiBackend struct {
|
||||||
|
|
@ -182,7 +183,7 @@ func (b *LesApiBackend) EventMux() *event.TypeMux {
|
||||||
return b.eth.eventMux
|
return b.eth.eventMux
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *LesApiBackend) ExternalSigner() string {
|
func (b *LesApiBackend) ExternalSigner() *ethapi.ExternalSignerAPI{
|
||||||
return b.eth.externalSigner
|
return b.eth.externalSigner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ type LightEthereum struct {
|
||||||
|
|
||||||
eventMux *event.TypeMux
|
eventMux *event.TypeMux
|
||||||
engine consensus.Engine
|
engine consensus.Engine
|
||||||
externalSigner string
|
externalSigner *ethapi.ExternalSignerAPI
|
||||||
|
|
||||||
networkId uint64
|
networkId uint64
|
||||||
netRPCService *ethapi.PublicNetAPI
|
netRPCService *ethapi.PublicNetAPI
|
||||||
|
|
|
||||||
|
|
@ -558,6 +558,9 @@ func (n *Node) SetExternalAPI(api *ethapi.ExternalSignerAPI){
|
||||||
n.extapi = api
|
n.extapi = api
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Node) ExternalSignerAPI() *ethapi.ExternalSignerAPI{
|
||||||
|
return n.extapi
|
||||||
|
}
|
||||||
// apis returns the collection of RPC descriptors this node offers.
|
// apis returns the collection of RPC descriptors this node offers.
|
||||||
func (n *Node) apis() []rpc.API {
|
func (n *Node) apis() []rpc.API {
|
||||||
return []rpc.API{
|
return []rpc.API{
|
||||||
|
|
|
||||||
|
|
@ -109,17 +109,17 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
|
||||||
fmt.Printf("\nWARNING: Invalid checksum on to-address!\n\n")
|
fmt.Printf("\nWARNING: Invalid checksum on to-address!\n\n")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("to: <contact creation>\n")
|
fmt.Printf("To: <contact creation>\n")
|
||||||
}
|
}
|
||||||
fmt.Printf("from: %v\n", request.Transaction.From.String())
|
fmt.Printf("Trom: %v\n", request.Transaction.From.String())
|
||||||
fmt.Printf("value: %v wei\n", weival)
|
fmt.Printf("Value: %v wei\n", weival)
|
||||||
fmt.Printf("gas: %v\n", request.Transaction.Gas)
|
fmt.Printf("Gas: %v\n", request.Transaction.Gas)
|
||||||
fmt.Printf("gasprice: %v wei\n", request.Transaction.GasPrice)
|
fmt.Printf("Gasprice: %v wei\n", request.Transaction.GasPrice.ToInt())
|
||||||
fmt.Printf("nonce: %v\n", request.Transaction.Nonce)
|
fmt.Printf("Nonce: %v\n", request.Transaction.Nonce)
|
||||||
if request.Transaction.Data != nil {
|
if request.Transaction.Data != nil {
|
||||||
d := *request.Transaction.Data
|
d := *request.Transaction.Data
|
||||||
if len(d) > 0 {
|
if len(d) > 0 {
|
||||||
fmt.Printf("data: %v\n", common.Bytes2Hex(d))
|
fmt.Printf("Data: %v\n", common.Bytes2Hex(d))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if request.Callinfo != nil {
|
if request.Callinfo != nil {
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ func (r *rulesetUI) ApproveImport(request *core.ImportRequest) (core.ImportRespo
|
||||||
return r.next.ApproveImport(request)
|
return r.next.ApproveImport(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *rulesetUI) ApproveListing(request *core.ListRequest) (core.ListAccountsResponse, error) {
|
func (r *rulesetUI) ApproveListing(request *core.ListAccountsRequest) (core.ListAccountsResponse, error) {
|
||||||
jsonreq, err := json.Marshal(request)
|
jsonreq, err := json.Marshal(request)
|
||||||
approved, err := r.checkApproval("ApproveListing", jsonreq, err)
|
approved, err := r.checkApproval("ApproveListing", jsonreq, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue