core/rawdb: restore TD freezer table for backward compatibility

This commit is contained in:
Gary Rong 2024-11-22 20:43:03 +08:00
parent 3b27580cc7
commit f2320d832c
2 changed files with 16 additions and 4 deletions

View file

@ -726,6 +726,14 @@ func writeAncientBlock(op ethdb.AncientWriteOp, block *types.Block, header *type
if err := op.Append(ChainFreezerReceiptTable, num, receipts); err != nil { if err := op.Append(ChainFreezerReceiptTable, num, receipts); err != nil {
return fmt.Errorf("can't append block %d receipts: %v", num, err) return fmt.Errorf("can't append block %d receipts: %v", num, err)
} }
// TODO (rjl493456442) TD has been deprecated and write garbage data for
// backward compatibility. See https://github.com/ethereum/go-ethereum/pull/30744/.
//
// The TD freezer table is retained for backward compatibility within this
// major version (1.14.x) and will be discarded in the next major version.
if err := op.Append(ChainFreezerDifficultyTable, num, big.NewInt(0)); err != nil {
return fmt.Errorf("can't append block %d total difficulty: %v", num, err)
}
return nil return nil
} }

View file

@ -35,15 +35,19 @@ const (
// ChainFreezerReceiptTable indicates the name of the freezer receipts table. // ChainFreezerReceiptTable indicates the name of the freezer receipts table.
ChainFreezerReceiptTable = "receipts" ChainFreezerReceiptTable = "receipts"
// ChainFreezerDifficultyTable indicates the name of the freezer total difficulty table.
ChainFreezerDifficultyTable = "diffs"
) )
// chainFreezerNoSnappy configures whether compression is disabled for the ancient-tables. // chainFreezerNoSnappy configures whether compression is disabled for the ancient-tables.
// Hashes and difficulties don't compress well. // Hashes and difficulties don't compress well.
var chainFreezerNoSnappy = map[string]bool{ var chainFreezerNoSnappy = map[string]bool{
ChainFreezerHeaderTable: false, ChainFreezerHeaderTable: false,
ChainFreezerHashTable: true, ChainFreezerHashTable: true,
ChainFreezerBodiesTable: false, ChainFreezerBodiesTable: false,
ChainFreezerReceiptTable: false, ChainFreezerReceiptTable: false,
ChainFreezerDifficultyTable: true,
} }
const ( const (