@ -37,7 +37,7 @@ import (
func ReadCanonicalHash ( db ethdb . Reader , number uint64 ) common . Hash {
var data [ ] byte
db . ReadAncients ( func ( reader ethdb . AncientReaderOp ) error {
data , _ = reader . Ancient ( c hainFreezerHashTable, number )
data , _ = reader . Ancient ( C hainFreezerHashTable, number )
if len ( data ) == 0 {
// Get it by hash from leveldb
data , _ = db . Get ( headerHashKey ( number ) )
@ -334,7 +334,7 @@ func ReadHeaderRange(db ethdb.Reader, number uint64, count uint64) []rlp.RawValu
}
// read remaining from ancients
max := count * 700
data , err := db . AncientRange ( c hainFreezerHeaderTable, i + 1 - count , count , max )
data , err := db . AncientRange ( C hainFreezerHeaderTable, i + 1 - count , count , max )
if err == nil && uint64 ( len ( data ) ) == count {
// the data is on the order [h, h+1, .., n] -- reordering needed
for i := range data {
@ -351,7 +351,7 @@ func ReadHeaderRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValu
// First try to look up the data in ancient database. Extra hash
// comparison is necessary since ancient database only maintains
// the canonical data.
data , _ = reader . Ancient ( c hainFreezerHeaderTable, number )
data , _ = reader . Ancient ( C hainFreezerHeaderTable, number )
if len ( data ) > 0 && crypto . Keccak256Hash ( data ) == hash {
return nil
}
@ -427,7 +427,7 @@ func deleteHeaderWithoutNumber(db ethdb.KeyValueWriter, hash common.Hash, number
// isCanon is an internal utility method, to check whether the given number/hash
// is part of the ancient (canon) set.
func isCanon ( reader ethdb . AncientReaderOp , number uint64 , hash common . Hash ) bool {
h , err := reader . Ancient ( c hainFreezerHashTable, number )
h , err := reader . Ancient ( C hainFreezerHashTable, number )
if err != nil {
return false
}
@ -443,7 +443,7 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue
db . ReadAncients ( func ( reader ethdb . AncientReaderOp ) error {
// Check if the data is in ancients
if isCanon ( reader , number , hash ) {
data , _ = reader . Ancient ( c hainFreezerBodiesTable, number )
data , _ = reader . Ancient ( C hainFreezerBodiesTable, number )
return nil
}
// If not, try reading from leveldb
@ -458,7 +458,7 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue
func ReadCanonicalBodyRLP ( db ethdb . Reader , number uint64 ) rlp . RawValue {
var data [ ] byte
db . ReadAncients ( func ( reader ethdb . AncientReaderOp ) error {
data , _ = reader . Ancient ( c hainFreezerBodiesTable, number )
data , _ = reader . Ancient ( C hainFreezerBodiesTable, number )
if len ( data ) > 0 {
return nil
}
@ -526,7 +526,7 @@ func ReadTdRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
db . ReadAncients ( func ( reader ethdb . AncientReaderOp ) error {
// Check if the data is in ancients
if isCanon ( reader , number , hash ) {
data , _ = reader . Ancient ( c hainFreezerDifficultyTable, number )
data , _ = reader . Ancient ( C hainFreezerDifficultyTable, number )
return nil
}
// If not, try reading from leveldb
@ -586,7 +586,7 @@ func ReadReceiptsRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawVa
db . ReadAncients ( func ( reader ethdb . AncientReaderOp ) error {
// Check if the data is in ancients
if isCanon ( reader , number , hash ) {
data , _ = reader . Ancient ( c hainFreezerReceiptTable, number )
data , _ = reader . Ancient ( C hainFreezerReceiptTable, number )
return nil
}
// If not, try reading from leveldb
@ -787,19 +787,19 @@ func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.Block, receipts
func writeAncientBlock ( op ethdb . AncientWriteOp , block * types . Block , header * types . Header , receipts [ ] * types . ReceiptForStorage , td * big . Int ) error {
num := block . NumberU64 ( )
if err := op . AppendRaw ( c hainFreezerHashTable, num , block . Hash ( ) . Bytes ( ) ) ; err != nil {
if err := op . AppendRaw ( C hainFreezerHashTable, num , block . Hash ( ) . Bytes ( ) ) ; err != nil {
return fmt . Errorf ( "can't add block %d hash: %v" , num , err )
}
if err := op . Append ( c hainFreezerHeaderTable, num , header ) ; err != nil {
if err := op . Append ( C hainFreezerHeaderTable, num , header ) ; err != nil {
return fmt . Errorf ( "can't append block header %d: %v" , num , err )
}
if err := op . Append ( c hainFreezerBodiesTable, num , block . Body ( ) ) ; err != nil {
if err := op . Append ( C hainFreezerBodiesTable, num , block . Body ( ) ) ; err != nil {
return fmt . Errorf ( "can't append block body %d: %v" , num , err )
}
if err := op . Append ( c hainFreezerReceiptTable, num , receipts ) ; err != nil {
if err := op . Append ( C hainFreezerReceiptTable, num , receipts ) ; err != nil {
return fmt . Errorf ( "can't append block %d receipts: %v" , num , err )
}
if err := op . Append ( c hainFreezerDifficultyTable, num , td ) ; err != nil {
if err := op . Append ( C hainFreezerDifficultyTable, num , td ) ; err != nil {
return fmt . Errorf ( "can't append block %d total difficulty: %v" , num , err )
}
return nil