@@ -102,8 +102,6 @@ var (
102102 errNoTrustedCht = errors .New ("no trusted canonical hash trie" )
103103 errNoTrustedBloomTrie = errors .New ("no trusted bloom trie" )
104104 errNoHeader = errors .New ("header not found" )
105- chtPrefix = []byte ("chtRootV2-" ) // chtPrefix + chtNum (uint64 big endian) -> trie root hash
106- ChtTablePrefix = "cht-"
107105)
108106
109107// ChtNode structures are stored in the Canonical Hash Trie in an RLP encoded format
@@ -116,15 +114,15 @@ type ChtNode struct {
116114func GetChtRoot (db ethdb.Database , sectionIdx uint64 , sectionHead common.Hash ) common.Hash {
117115 var encNumber [8 ]byte
118116 binary .BigEndian .PutUint64 (encNumber [:], sectionIdx )
119- data , _ := db .Get (append (append (chtPrefix , encNumber [:]... ), sectionHead .Bytes ()... ))
117+ data , _ := db .Get (append (append (rawdb . ChtPrefix , encNumber [:]... ), sectionHead .Bytes ()... ))
120118 return common .BytesToHash (data )
121119}
122120
123121// StoreChtRoot writes the CHT root associated to the given section into the database
124122func StoreChtRoot (db ethdb.Database , sectionIdx uint64 , sectionHead , root common.Hash ) {
125123 var encNumber [8 ]byte
126124 binary .BigEndian .PutUint64 (encNumber [:], sectionIdx )
127- db .Put (append (append (chtPrefix , encNumber [:]... ), sectionHead .Bytes ()... ), root .Bytes ())
125+ db .Put (append (append (rawdb . ChtPrefix , encNumber [:]... ), sectionHead .Bytes ()... ), root .Bytes ())
128126}
129127
130128// ChtIndexerBackend implements core.ChainIndexerBackend.
@@ -140,7 +138,7 @@ type ChtIndexerBackend struct {
140138
141139// NewChtIndexer creates a Cht chain indexer
142140func NewChtIndexer (db ethdb.Database , odr OdrBackend , size , confirms uint64 , disablePruning bool ) * core.ChainIndexer {
143- trieTable := rawdb .NewTable (db , ChtTablePrefix )
141+ trieTable := rawdb .NewTable (db , string ( rawdb . ChtTablePrefix ) )
144142 backend := & ChtIndexerBackend {
145143 diskdb : db ,
146144 odr : odr ,
@@ -149,7 +147,7 @@ func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64, dis
149147 sectionSize : size ,
150148 disablePruning : disablePruning ,
151149 }
152- return core .NewChainIndexer (db , rawdb .NewTable (db , "chtIndexV2-" ), backend , size , confirms , time .Millisecond * 100 , "cht" )
150+ return core .NewChainIndexer (db , rawdb .NewTable (db , string ( rawdb . ChtIndexTablePrefix ) ), backend , size , confirms , time .Millisecond * 100 , "cht" )
153151}
154152
155153// fetchMissingNodes tries to retrieve the last entry of the latest trusted CHT from the
@@ -249,7 +247,7 @@ func (c *ChtIndexerBackend) Commit() error {
249247 }
250248 }
251249 for it .Next () {
252- trimmed := bytes .TrimPrefix (it .Key (), [] byte ( ChtTablePrefix ) )
250+ trimmed := bytes .TrimPrefix (it .Key (), rawdb . ChtTablePrefix )
253251 if len (trimmed ) == common .HashLength {
254252 if _ , ok := hashes [common .BytesToHash (trimmed )]; ! ok {
255253 batch .Delete (trimmed )
@@ -311,24 +309,19 @@ func (c *ChtIndexerBackend) Prune(threshold uint64) error {
311309 return nil
312310}
313311
314- var (
315- bloomTriePrefix = []byte ("bltRoot-" ) // bloomTriePrefix + bloomTrieNum (uint64 big endian) -> trie root hash
316- BloomTrieTablePrefix = "blt-"
317- )
318-
319312// GetBloomTrieRoot reads the BloomTrie root associated to the given section from the database
320313func GetBloomTrieRoot (db ethdb.Database , sectionIdx uint64 , sectionHead common.Hash ) common.Hash {
321314 var encNumber [8 ]byte
322315 binary .BigEndian .PutUint64 (encNumber [:], sectionIdx )
323- data , _ := db .Get (append (append (bloomTriePrefix , encNumber [:]... ), sectionHead .Bytes ()... ))
316+ data , _ := db .Get (append (append (rawdb . BloomTriePrefix , encNumber [:]... ), sectionHead .Bytes ()... ))
324317 return common .BytesToHash (data )
325318}
326319
327320// StoreBloomTrieRoot writes the BloomTrie root associated to the given section into the database
328321func StoreBloomTrieRoot (db ethdb.Database , sectionIdx uint64 , sectionHead , root common.Hash ) {
329322 var encNumber [8 ]byte
330323 binary .BigEndian .PutUint64 (encNumber [:], sectionIdx )
331- db .Put (append (append (bloomTriePrefix , encNumber [:]... ), sectionHead .Bytes ()... ), root .Bytes ())
324+ db .Put (append (append (rawdb . BloomTriePrefix , encNumber [:]... ), sectionHead .Bytes ()... ), root .Bytes ())
332325}
333326
334327// BloomTrieIndexerBackend implements core.ChainIndexerBackend
@@ -347,7 +340,7 @@ type BloomTrieIndexerBackend struct {
347340
348341// NewBloomTrieIndexer creates a BloomTrie chain indexer
349342func NewBloomTrieIndexer (db ethdb.Database , odr OdrBackend , parentSize , size uint64 , disablePruning bool ) * core.ChainIndexer {
350- trieTable := rawdb .NewTable (db , BloomTrieTablePrefix )
343+ trieTable := rawdb .NewTable (db , string ( rawdb . BloomTrieTablePrefix ) )
351344 backend := & BloomTrieIndexerBackend {
352345 diskdb : db ,
353346 odr : odr ,
@@ -359,7 +352,7 @@ func NewBloomTrieIndexer(db ethdb.Database, odr OdrBackend, parentSize, size uin
359352 }
360353 backend .bloomTrieRatio = size / parentSize
361354 backend .sectionHeads = make ([]common.Hash , backend .bloomTrieRatio )
362- return core .NewChainIndexer (db , rawdb .NewTable (db , "bltIndex-" ), backend , size , 0 , time .Millisecond * 100 , "bloomtrie" )
355+ return core .NewChainIndexer (db , rawdb .NewTable (db , string ( rawdb . BloomTrieIndexPrefix ) ), backend , size , 0 , time .Millisecond * 100 , "bloomtrie" )
363356}
364357
365358// fetchMissingNodes tries to retrieve the last entries of the latest trusted bloom trie from the
@@ -500,7 +493,7 @@ func (b *BloomTrieIndexerBackend) Commit() error {
500493 }
501494 }
502495 for it .Next () {
503- trimmed := bytes .TrimPrefix (it .Key (), [] byte ( BloomTrieTablePrefix ) )
496+ trimmed := bytes .TrimPrefix (it .Key (), rawdb . BloomTrieTablePrefix )
504497 if len (trimmed ) == common .HashLength {
505498 if _ , ok := hashes [common .BytesToHash (trimmed )]; ! ok {
506499 batch .Delete (trimmed )
0 commit comments