core, eth: clean up bloom filtering, add some tests
This commit is contained in:
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/consensus/clique"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/bloombits"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
@@ -77,7 +78,8 @@ type Ethereum struct {
|
||||
engine consensus.Engine
|
||||
accountManager *accounts.Manager
|
||||
|
||||
bbIndexer *core.ChainIndexer
|
||||
bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests
|
||||
bloomIndexer *core.ChainIndexer // Bloom indexer operating during block imports
|
||||
|
||||
ApiBackend *EthApiBackend
|
||||
|
||||
@@ -127,7 +129,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||
networkId: config.NetworkId,
|
||||
gasPrice: config.GasPrice,
|
||||
etherbase: config.Etherbase,
|
||||
bbIndexer: NewBloomBitsProcessor(chainDb, bloomBitsSection),
|
||||
bloomRequests: make(chan chan *bloombits.Retrieval),
|
||||
bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks),
|
||||
}
|
||||
|
||||
log.Info("Initialising Ethereum protocol", "versions", ProtocolVersions, "network", config.NetworkId)
|
||||
@@ -151,7 +154,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||
eth.blockchain.SetHead(compat.RewindTo)
|
||||
core.WriteChainConfig(chainDb, genesisHash, chainConfig)
|
||||
}
|
||||
eth.bbIndexer.Start(eth.blockchain)
|
||||
eth.bloomIndexer.Start(eth.blockchain.CurrentHeader(), eth.blockchain.SubscribeChainEvent)
|
||||
|
||||
if config.TxPool.Journal != "" {
|
||||
config.TxPool.Journal = ctx.ResolvePath(config.TxPool.Journal)
|
||||
@@ -261,7 +264,7 @@ func (s *Ethereum) APIs() []rpc.API {
|
||||
}, {
|
||||
Namespace: "eth",
|
||||
Version: "1.0",
|
||||
Service: filters.NewPublicFilterAPI(s.ApiBackend, false, bloomBitsSection),
|
||||
Service: filters.NewPublicFilterAPI(s.ApiBackend, false),
|
||||
Public: true,
|
||||
}, {
|
||||
Namespace: "admin",
|
||||
@@ -359,14 +362,17 @@ func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManage
|
||||
func (s *Ethereum) Protocols() []p2p.Protocol {
|
||||
if s.lesServer == nil {
|
||||
return s.protocolManager.SubProtocols
|
||||
} else {
|
||||
return append(s.protocolManager.SubProtocols, s.lesServer.Protocols()...)
|
||||
}
|
||||
return append(s.protocolManager.SubProtocols, s.lesServer.Protocols()...)
|
||||
}
|
||||
|
||||
// Start implements node.Service, starting all internal goroutines needed by the
|
||||
// Ethereum protocol implementation.
|
||||
func (s *Ethereum) Start(srvr *p2p.Server) error {
|
||||
// Start the bloom bits servicing goroutines
|
||||
s.startBloomHandlers()
|
||||
|
||||
// Start the RPC service
|
||||
s.netRPCService = ethapi.NewPublicNetAPI(srvr, s.NetVersion())
|
||||
|
||||
// Figure out a max peers count based on the server limits
|
||||
@@ -377,6 +383,7 @@ func (s *Ethereum) Start(srvr *p2p.Server) error {
|
||||
maxPeers = srvr.MaxPeers / 2
|
||||
}
|
||||
}
|
||||
// Start the networking layer and the light server if requested
|
||||
s.protocolManager.Start(maxPeers)
|
||||
if s.lesServer != nil {
|
||||
s.lesServer.Start(srvr)
|
||||
@@ -390,7 +397,7 @@ func (s *Ethereum) Stop() error {
|
||||
if s.stopDbUpgrade != nil {
|
||||
s.stopDbUpgrade()
|
||||
}
|
||||
s.bbIndexer.Close()
|
||||
s.bloomIndexer.Close()
|
||||
s.blockchain.Stop()
|
||||
s.protocolManager.Stop()
|
||||
if s.lesServer != nil {
|
||||
|
Reference in New Issue
Block a user