@@ -41,9 +41,6 @@ type IndexerConfig struct {
4141 // The block frequency for creating CHTs.
4242 ChtSize uint64
4343
44- // A special auxiliary field represents client's chtsize for server config, otherwise represents server's chtsize.
45- PairChtSize uint64
46-
4744 // The number of confirmations needed to generate/accept a canonical hash help trie.
4845 ChtConfirms uint64
4946
@@ -64,8 +61,7 @@ type IndexerConfig struct {
6461var (
6562 // DefaultServerIndexerConfig wraps a set of configs as a default indexer config for server side.
6663 DefaultServerIndexerConfig = & IndexerConfig {
67- ChtSize : params .CHTFrequencyServer ,
68- PairChtSize : params .CHTFrequencyClient ,
64+ ChtSize : params .CHTFrequency ,
6965 ChtConfirms : params .HelperTrieProcessConfirmations ,
7066 BloomSize : params .BloomBitsBlocks ,
7167 BloomConfirms : params .BloomConfirms ,
7470 }
7571 // DefaultClientIndexerConfig wraps a set of configs as a default indexer config for client side.
7672 DefaultClientIndexerConfig = & IndexerConfig {
77- ChtSize : params .CHTFrequencyClient ,
78- PairChtSize : params .CHTFrequencyServer ,
73+ ChtSize : params .CHTFrequency ,
7974 ChtConfirms : params .HelperTrieConfirmations ,
8075 BloomSize : params .BloomBitsBlocksClient ,
8176 BloomConfirms : params .HelperTrieConfirmations ,
8479 }
8580 // TestServerIndexerConfig wraps a set of configs as a test indexer config for server side.
8681 TestServerIndexerConfig = & IndexerConfig {
87- ChtSize : 64 ,
88- PairChtSize : 512 ,
82+ ChtSize : 512 ,
8983 ChtConfirms : 4 ,
9084 BloomSize : 64 ,
9185 BloomConfirms : 4 ,
9589 // TestClientIndexerConfig wraps a set of configs as a test indexer config for client side.
9690 TestClientIndexerConfig = & IndexerConfig {
9791 ChtSize : 512 ,
98- PairChtSize : 64 ,
9992 ChtConfirms : 32 ,
10093 BloomSize : 512 ,
10194 BloomConfirms : 32 ,
@@ -116,7 +109,7 @@ var (
116109 ErrNoTrustedCht = errors .New ("no trusted canonical hash trie" )
117110 ErrNoTrustedBloomTrie = errors .New ("no trusted bloom trie" )
118111 ErrNoHeader = errors .New ("header not found" )
119- chtPrefix = []byte ("chtRoot -" ) // chtPrefix + chtNum (uint64 big endian) -> trie root hash
112+ chtPrefix = []byte ("chtRootV2 -" ) // chtPrefix + chtNum (uint64 big endian) -> trie root hash
120113 ChtTablePrefix = "cht-"
121114)
122115
@@ -127,7 +120,6 @@ type ChtNode struct {
127120}
128121
129122// GetChtRoot reads the CHT root associated to the given section from the database
130- // Note that sectionIdx is specified according to LES/1 CHT section size.
131123func GetChtRoot (db ethdb.Database , sectionIdx uint64 , sectionHead common.Hash ) common.Hash {
132124 var encNumber [8 ]byte
133125 binary .BigEndian .PutUint64 (encNumber [:], sectionIdx )
@@ -136,7 +128,6 @@ func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) c
136128}
137129
138130// StoreChtRoot writes the CHT root associated to the given section into the database
139- // Note that sectionIdx is specified according to LES/1 CHT section size.
140131func StoreChtRoot (db ethdb.Database , sectionIdx uint64 , sectionHead , root common.Hash ) {
141132 var encNumber [8 ]byte
142133 binary .BigEndian .PutUint64 (encNumber [:], sectionIdx )
@@ -163,7 +154,7 @@ func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64) *co
163154 triedb : trie .NewDatabaseWithCache (trieTable , 1 ), // Use a tiny cache only to keep memory down
164155 sectionSize : size ,
165156 }
166- return core .NewChainIndexer (db , rawdb .NewTable (db , "chtIndex -" ), backend , size , confirms , time .Millisecond * 100 , "cht" )
157+ return core .NewChainIndexer (db , rawdb .NewTable (db , "chtIndexV2 -" ), backend , size , confirms , time .Millisecond * 100 , "cht" )
167158}
168159
169160// fetchMissingNodes tries to retrieve the last entry of the latest trusted CHT from the
@@ -235,9 +226,7 @@ func (c *ChtIndexerBackend) Commit() error {
235226 }
236227 c .triedb .Commit (root , false )
237228
238- if ((c .section + 1 )* c .sectionSize )% params .CHTFrequencyClient == 0 {
239- log .Info ("Storing CHT" , "section" , c .section * c .sectionSize / params .CHTFrequencyClient , "head" , fmt .Sprintf ("%064x" , c .lastHash ), "root" , fmt .Sprintf ("%064x" , root ))
240- }
229+ log .Info ("Storing CHT" , "section" , c .section , "head" , fmt .Sprintf ("%064x" , c .lastHash ), "root" , fmt .Sprintf ("%064x" , root ))
241230 StoreChtRoot (c .diskdb , c .section , c .lastHash , root )
242231 return nil
243232}
0 commit comments