aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2018-08-28 15:08:16 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-08-28 15:08:16 +0800
commitb69476b372a26679e5bdb33db3d508f2c955e7ff (patch)
tree47757ef2b65302f19aca96327b7a34ad73f652a5 /eth
parentc64d72bea207ccaca3f6aded25d8730a4b8696cd (diff)
downloadgo-tangerine-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar
go-tangerine-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.gz
go-tangerine-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.bz2
go-tangerine-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.lz
go-tangerine-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.xz
go-tangerine-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.zst
go-tangerine-b69476b372a26679e5bdb33db3d508f2c955e7ff.zip
all: make indexer configurable (#17188)
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go4
-rw-r--r--eth/bloombits.go15
2 files changed, 7 insertions, 12 deletions
diff --git a/eth/backend.go b/eth/backend.go
index c530d3c7c..da7e0b2cd 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -136,7 +136,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
gasPrice: config.MinerGasPrice,
etherbase: config.Etherbase,
bloomRequests: make(chan chan *bloombits.Retrieval),
- bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks, bloomConfirms),
+ bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms),
}
log.Info("Initialising Ethereum protocol", "versions", ProtocolVersions, "network", config.NetworkId)
@@ -426,7 +426,7 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
// Ethereum protocol implementation.
func (s *Ethereum) Start(srvr *p2p.Server) error {
// Start the bloom bits servicing goroutines
- s.startBloomHandlers()
+ s.startBloomHandlers(params.BloomBitsBlocks)
// Start the RPC service
s.netRPCService = ethapi.NewPublicNetAPI(srvr, s.NetVersion())
diff --git a/eth/bloombits.go b/eth/bloombits.go
index eb18565e2..c7bb56140 100644
--- a/eth/bloombits.go
+++ b/eth/bloombits.go
@@ -27,7 +27,6 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
)
const (
@@ -50,7 +49,7 @@ const (
// startBloomHandlers starts a batch of goroutines to accept bloom bit database
// retrievals from possibly a range of filters and serving the data to satisfy.
-func (eth *Ethereum) startBloomHandlers() {
+func (eth *Ethereum) startBloomHandlers(sectionSize uint64) {
for i := 0; i < bloomServiceThreads; i++ {
go func() {
for {
@@ -62,9 +61,9 @@ func (eth *Ethereum) startBloomHandlers() {
task := <-request
task.Bitsets = make([][]byte, len(task.Sections))
for i, section := range task.Sections {
- head := rawdb.ReadCanonicalHash(eth.chainDb, (section+1)*params.BloomBitsBlocks-1)
+ head := rawdb.ReadCanonicalHash(eth.chainDb, (section+1)*sectionSize-1)
if compVector, err := rawdb.ReadBloomBits(eth.chainDb, task.Bit, section, head); err == nil {
- if blob, err := bitutil.DecompressBytes(compVector, int(params.BloomBitsBlocks)/8); err == nil {
+ if blob, err := bitutil.DecompressBytes(compVector, int(sectionSize/8)); err == nil {
task.Bitsets[i] = blob
} else {
task.Error = err
@@ -81,10 +80,6 @@ func (eth *Ethereum) startBloomHandlers() {
}
const (
- // bloomConfirms is the number of confirmation blocks before a bloom section is
- // considered probably final and its rotated bits are calculated.
- bloomConfirms = 256
-
// bloomThrottling is the time to wait between processing two consecutive index
// sections. It's useful during chain upgrades to prevent disk overload.
bloomThrottling = 100 * time.Millisecond
@@ -102,14 +97,14 @@ type BloomIndexer struct {
// NewBloomIndexer returns a chain indexer that generates bloom bits data for the
// canonical chain for fast logs filtering.
-func NewBloomIndexer(db ethdb.Database, size, confReq uint64) *core.ChainIndexer {
+func NewBloomIndexer(db ethdb.Database, size, confirms uint64) *core.ChainIndexer {
backend := &BloomIndexer{
db: db,
size: size,
}
table := ethdb.NewTable(db, string(rawdb.BloomBitsIndexPrefix))
- return core.NewChainIndexer(db, table, backend, size, confReq, bloomThrottling, "bloombits")
+ return core.NewChainIndexer(db, table, backend, size, confirms, bloomThrottling, "bloombits")
}
// Reset implements core.ChainIndexerBackend, starting a new bloombits index