aboutsummaryrefslogtreecommitdiffstats
path: root/light/lightchain.go
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 /light/lightchain.go
parentc64d72bea207ccaca3f6aded25d8730a4b8696cd (diff)
downloaddexon-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar
dexon-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.gz
dexon-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.bz2
dexon-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.lz
dexon-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.xz
dexon-b69476b372a26679e5bdb33db3d508f2c955e7ff.tar.zst
dexon-b69476b372a26679e5bdb33db3d508f2c955e7ff.zip
all: make indexer configurable (#17188)
Diffstat (limited to 'light/lightchain.go')
-rw-r--r--light/lightchain.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/light/lightchain.go b/light/lightchain.go
index b5afe1f0e..bd798eca2 100644
--- a/light/lightchain.go
+++ b/light/lightchain.go
@@ -48,6 +48,7 @@ var (
// interface. It only does header validation during chain insertion.
type LightChain struct {
hc *core.HeaderChain
+ indexerConfig *IndexerConfig
chainDb ethdb.Database
odr OdrBackend
chainFeed event.Feed
@@ -81,13 +82,14 @@ func NewLightChain(odr OdrBackend, config *params.ChainConfig, engine consensus.
blockCache, _ := lru.New(blockCacheLimit)
bc := &LightChain{
- chainDb: odr.Database(),
- odr: odr,
- quit: make(chan struct{}),
- bodyCache: bodyCache,
- bodyRLPCache: bodyRLPCache,
- blockCache: blockCache,
- engine: engine,
+ chainDb: odr.Database(),
+ indexerConfig: odr.IndexerConfig(),
+ odr: odr,
+ quit: make(chan struct{}),
+ bodyCache: bodyCache,
+ bodyRLPCache: bodyRLPCache,
+ blockCache: blockCache,
+ engine: engine,
}
var err error
bc.hc, err = core.NewHeaderChain(odr.Database(), config, bc.engine, bc.getProcInterrupt)
@@ -128,7 +130,7 @@ func (self *LightChain) addTrustedCheckpoint(cp TrustedCheckpoint) {
if self.odr.BloomIndexer() != nil {
self.odr.BloomIndexer().AddKnownSectionHead(cp.SectionIdx, cp.SectionHead)
}
- log.Info("Added trusted checkpoint", "chain", cp.name, "block", (cp.SectionIdx+1)*CHTFrequencyClient-1, "hash", cp.SectionHead)
+ log.Info("Added trusted checkpoint", "chain", cp.name, "block", (cp.SectionIdx+1)*self.indexerConfig.ChtSize-1, "hash", cp.SectionHead)
}
func (self *LightChain) getProcInterrupt() bool {
@@ -472,7 +474,7 @@ func (self *LightChain) SyncCht(ctx context.Context) bool {
head := self.CurrentHeader().Number.Uint64()
sections, _, _ := self.odr.ChtIndexer().Sections()
- latest := sections*CHTFrequencyClient - 1
+ latest := sections*self.indexerConfig.ChtSize - 1
if clique := self.hc.Config().Clique; clique != nil {
latest -= latest % clique.Epoch // epoch snapshot for clique
}