mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
fix
This commit is contained in:
parent
4de92570cc
commit
f62fd849d5
5 changed files with 39 additions and 16 deletions
|
|
@ -133,7 +133,7 @@ type FullNodeService struct {
|
||||||
httpclient *httpclient.HTTPClient
|
httpclient *httpclient.HTTPClient
|
||||||
accountManager *accounts.Manager
|
accountManager *accounts.Manager
|
||||||
|
|
||||||
apiBackend *EthApiBackend
|
ApiBackend *EthApiBackend
|
||||||
|
|
||||||
miner *miner.Miner
|
miner *miner.Miner
|
||||||
Mining bool
|
Mining bool
|
||||||
|
|
@ -251,7 +251,7 @@ func New(ctx *node.ServiceContext, config *Config) (*FullNodeService, error) {
|
||||||
GpobaseCorrectionFactor: config.GpobaseCorrectionFactor,
|
GpobaseCorrectionFactor: config.GpobaseCorrectionFactor,
|
||||||
}
|
}
|
||||||
gpo := gasprice.NewGasPriceOracle(eth.blockchain, chainDb, eth.eventMux, gpoParams)
|
gpo := gasprice.NewGasPriceOracle(eth.blockchain, chainDb, eth.eventMux, gpoParams)
|
||||||
eth.apiBackend = &EthApiBackend{eth, gpo}
|
eth.ApiBackend = &EthApiBackend{eth, gpo}
|
||||||
|
|
||||||
return eth, nil
|
return eth, nil
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +318,7 @@ 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 *FullNodeService) 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",
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,11 @@ 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(apiBackend ethapi.Backend) *ContractBackend {
|
||||||
return &ContractBackend{
|
return &ContractBackend{
|
||||||
eapi: ethapi.NewPublicEthereumAPI(eth.apiBackend, nil, nil),
|
eapi: ethapi.NewPublicEthereumAPI(apiBackend, nil, nil),
|
||||||
bcapi: ethapi.NewPublicBlockChainAPI(eth.apiBackend),
|
bcapi: ethapi.NewPublicBlockChainAPI(apiBackend),
|
||||||
txapi: ethapi.NewPublicTransactionPoolAPI(eth.apiBackend),
|
txapi: ethapi.NewPublicTransactionPoolAPI(apiBackend),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1648,10 +1648,23 @@ func (d *Downloader) processHeaders(origin uint64, td *big.Int) error {
|
||||||
for i, header := range rollback {
|
for i, header := range rollback {
|
||||||
hashes[i] = header.Hash()
|
hashes[i] = header.Hash()
|
||||||
}
|
}
|
||||||
lastHeader, lastFastBlock, lastBlock := d.headHeader().Number, d.headFastBlock().Number(), d.headBlock().Number()
|
lastHeader, lastFastBlock, lastBlock := d.headHeader().Number, common.Big0, common.Big0
|
||||||
|
if d.headFastBlock != nil {
|
||||||
|
lastFastBlock = d.headFastBlock().Number()
|
||||||
|
}
|
||||||
|
if d.headBlock != nil {
|
||||||
|
lastBlock = d.headBlock().Number()
|
||||||
|
}
|
||||||
d.rollback(hashes)
|
d.rollback(hashes)
|
||||||
|
curFastBlock, curBlock := common.Big0, common.Big0
|
||||||
|
if d.headFastBlock != nil {
|
||||||
|
curFastBlock = d.headFastBlock().Number()
|
||||||
|
}
|
||||||
|
if d.headBlock != nil {
|
||||||
|
curBlock = d.headBlock().Number()
|
||||||
|
}
|
||||||
glog.V(logger.Warn).Infof("Rolled back %d headers (LH: %d->%d, FB: %d->%d, LB: %d->%d)",
|
glog.V(logger.Warn).Infof("Rolled back %d headers (LH: %d->%d, FB: %d->%d, LB: %d->%d)",
|
||||||
len(hashes), lastHeader, d.headHeader().Number, lastFastBlock, d.headFastBlock().Number(), lastBlock, d.headBlock().Number())
|
len(hashes), lastHeader, d.headHeader().Number, lastFastBlock, curFastBlock, lastBlock, curBlock)
|
||||||
|
|
||||||
// If we're already past the pivot point, this could be an attack, thread carefully
|
// If we're already past the pivot point, this could be an attack, thread carefully
|
||||||
if rollback[len(rollback)-1].Number.Uint64() > pivot {
|
if rollback[len(rollback)-1].Number.Uint64() > pivot {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ type LightNodeService struct {
|
||||||
chainDb ethdb.Database // Block chain database
|
chainDb ethdb.Database // Block chain database
|
||||||
dappDb ethdb.Database // Dapp database
|
dappDb ethdb.Database // Dapp database
|
||||||
|
|
||||||
apiBackend *LesApiBackend
|
ApiBackend *LesApiBackend
|
||||||
|
|
||||||
eventMux *event.TypeMux
|
eventMux *event.TypeMux
|
||||||
pow *ethash.Ethash
|
pow *ethash.Ethash
|
||||||
|
|
@ -123,15 +123,15 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightNodeService, error
|
||||||
}
|
}
|
||||||
odr.removePeer = eth.protocolManager.removePeer
|
odr.removePeer = eth.protocolManager.removePeer
|
||||||
|
|
||||||
eth.apiBackend = &LesApiBackend{eth, nil}
|
eth.ApiBackend = &LesApiBackend{eth, nil}
|
||||||
eth.apiBackend.gpo = gasprice.NewLightPriceOracle(eth.apiBackend)
|
eth.ApiBackend.gpo = gasprice.NewLightPriceOracle(eth.ApiBackend)
|
||||||
return eth, nil
|
return eth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 *LightNodeService) APIs() []rpc.API {
|
func (s *LightNodeService) 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",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
|
"github.com/ethereum/go-ethereum/les"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"github.com/ethereum/go-ethereum/logger/glog"
|
"github.com/ethereum/go-ethereum/logger/glog"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
|
|
@ -58,12 +60,20 @@ 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 apiBackend ethapi.Backend
|
||||||
var ethereum *eth.FullNodeService
|
var ethereum *eth.FullNodeService
|
||||||
if err := ctx.Service(ðereum); err != nil {
|
if err := ctx.Service(ðereum); err == nil {
|
||||||
return nil, err
|
apiBackend = ethereum.ApiBackend
|
||||||
|
} else {
|
||||||
|
var ethereum *les.LightNodeService
|
||||||
|
if err := ctx.Service(ðereum); err == nil {
|
||||||
|
apiBackend = ethereum.ApiBackend
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Construct the release service
|
// Construct the release service
|
||||||
contract, err := NewReleaseOracle(config.Oracle, eth.NewContractBackend(ethereum))
|
contract, err := NewReleaseOracle(config.Oracle, eth.NewContractBackend(apiBackend))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue