aboutsummaryrefslogtreecommitdiffstats
path: root/light/postprocess.go
diff options
context:
space:
mode:
authorZsolt Felfoldi <zsfelfoldi@gmail.com>2019-04-05 23:40:03 +0800
committerZsolt Felfoldi <zsfelfoldi@gmail.com>2019-04-08 19:17:24 +0800
commit64f9c1ea0984141623843abfa9262fc9401192f2 (patch)
tree72b6e966a4705446bf2a05ad84ba84786aef3009 /light/postprocess.go
parent5515f364ae1673c1bf5569c089b5853c90ea1655 (diff)
downloadgo-tangerine-64f9c1ea0984141623843abfa9262fc9401192f2.tar
go-tangerine-64f9c1ea0984141623843abfa9262fc9401192f2.tar.gz
go-tangerine-64f9c1ea0984141623843abfa9262fc9401192f2.tar.bz2
go-tangerine-64f9c1ea0984141623843abfa9262fc9401192f2.tar.lz
go-tangerine-64f9c1ea0984141623843abfa9262fc9401192f2.tar.xz
go-tangerine-64f9c1ea0984141623843abfa9262fc9401192f2.tar.zst
go-tangerine-64f9c1ea0984141623843abfa9262fc9401192f2.zip
les, light: remove support for les/1 4096 block CHT sections
Diffstat (limited to 'light/postprocess.go')
-rw-r--r--light/postprocess.go23
1 files changed, 6 insertions, 17 deletions
diff --git a/light/postprocess.go b/light/postprocess.go
index 306de4694..2a837e6c1 100644
--- a/light/postprocess.go
+++ b/light/postprocess.go
@@ -41,9 +41,6 @@ type IndexerConfig struct {
// The block frequency for creating CHTs.
ChtSize uint64
- // A special auxiliary field represents client's chtsize for server config, otherwise represents server's chtsize.
- PairChtSize uint64
-
// The number of confirmations needed to generate/accept a canonical hash help trie.
ChtConfirms uint64
@@ -64,8 +61,7 @@ type IndexerConfig struct {
var (
// DefaultServerIndexerConfig wraps a set of configs as a default indexer config for server side.
DefaultServerIndexerConfig = &IndexerConfig{
- ChtSize: params.CHTFrequencyServer,
- PairChtSize: params.CHTFrequencyClient,
+ ChtSize: params.CHTFrequency,
ChtConfirms: params.HelperTrieProcessConfirmations,
BloomSize: params.BloomBitsBlocks,
BloomConfirms: params.BloomConfirms,
@@ -74,8 +70,7 @@ var (
}
// DefaultClientIndexerConfig wraps a set of configs as a default indexer config for client side.
DefaultClientIndexerConfig = &IndexerConfig{
- ChtSize: params.CHTFrequencyClient,
- PairChtSize: params.CHTFrequencyServer,
+ ChtSize: params.CHTFrequency,
ChtConfirms: params.HelperTrieConfirmations,
BloomSize: params.BloomBitsBlocksClient,
BloomConfirms: params.HelperTrieConfirmations,
@@ -84,8 +79,7 @@ var (
}
// TestServerIndexerConfig wraps a set of configs as a test indexer config for server side.
TestServerIndexerConfig = &IndexerConfig{
- ChtSize: 64,
- PairChtSize: 512,
+ ChtSize: 512,
ChtConfirms: 4,
BloomSize: 64,
BloomConfirms: 4,
@@ -95,7 +89,6 @@ var (
// TestClientIndexerConfig wraps a set of configs as a test indexer config for client side.
TestClientIndexerConfig = &IndexerConfig{
ChtSize: 512,
- PairChtSize: 64,
ChtConfirms: 32,
BloomSize: 512,
BloomConfirms: 32,
@@ -116,7 +109,7 @@ var (
ErrNoTrustedCht = errors.New("no trusted canonical hash trie")
ErrNoTrustedBloomTrie = errors.New("no trusted bloom trie")
ErrNoHeader = errors.New("header not found")
- chtPrefix = []byte("chtRoot-") // chtPrefix + chtNum (uint64 big endian) -> trie root hash
+ chtPrefix = []byte("chtRootV2-") // chtPrefix + chtNum (uint64 big endian) -> trie root hash
ChtTablePrefix = "cht-"
)
@@ -127,7 +120,6 @@ type ChtNode struct {
}
// GetChtRoot reads the CHT root associated to the given section from the database
-// Note that sectionIdx is specified according to LES/1 CHT section size.
func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) common.Hash {
var encNumber [8]byte
binary.BigEndian.PutUint64(encNumber[:], sectionIdx)
@@ -136,7 +128,6 @@ func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) c
}
// StoreChtRoot writes the CHT root associated to the given section into the database
-// Note that sectionIdx is specified according to LES/1 CHT section size.
func StoreChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead, root common.Hash) {
var encNumber [8]byte
binary.BigEndian.PutUint64(encNumber[:], sectionIdx)
@@ -163,7 +154,7 @@ func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64) *co
triedb: trie.NewDatabaseWithCache(trieTable, 1), // Use a tiny cache only to keep memory down
sectionSize: size,
}
- return core.NewChainIndexer(db, rawdb.NewTable(db, "chtIndex-"), backend, size, confirms, time.Millisecond*100, "cht")
+ return core.NewChainIndexer(db, rawdb.NewTable(db, "chtIndexV2-"), backend, size, confirms, time.Millisecond*100, "cht")
}
// fetchMissingNodes tries to retrieve the last entry of the latest trusted CHT from the
@@ -235,9 +226,7 @@ func (c *ChtIndexerBackend) Commit() error {
}
c.triedb.Commit(root, false)
- if ((c.section+1)*c.sectionSize)%params.CHTFrequencyClient == 0 {
- log.Info("Storing CHT", "section", c.section*c.sectionSize/params.CHTFrequencyClient, "head", fmt.Sprintf("%064x", c.lastHash), "root", fmt.Sprintf("%064x", root))
- }
+ log.Info("Storing CHT", "section", c.section, "head", fmt.Sprintf("%064x", c.lastHash), "root", fmt.Sprintf("%064x", root))
StoreChtRoot(c.diskdb, c.section, c.lastHash, root)
return nil
}