core/rawdb, ethdb: fix comments

This commit is contained in:
Gary Rong 2025-03-16 20:48:31 +08:00
parent a32eaccaee
commit 3143880dd3
3 changed files with 9 additions and 8 deletions

View file

@ -37,8 +37,10 @@ const (
ChainFreezerReceiptTable = "receipts" ChainFreezerReceiptTable = "receipts"
) )
// chainFreezerTableConfigs configures whether compression is disabled for the ancient-tables. // chainFreezerTableConfigs configures the settings for tables in the chain freezer.
// Hashes and difficulties don't compress well. // Compression is disabled for hashes as they don't compress well. Additionally,
// tail truncation is disabled for the header and hash tables, as these are intended
// to be retained long-term.
var chainFreezerTableConfigs = map[string]freezerTableConfig{ var chainFreezerTableConfigs = map[string]freezerTableConfig{
ChainFreezerHeaderTable: {noSnappy: false, prunable: false}, ChainFreezerHeaderTable: {noSnappy: false, prunable: false},
ChainFreezerHashTable: {noSnappy: true, prunable: false}, ChainFreezerHashTable: {noSnappy: true, prunable: false},
@ -46,6 +48,7 @@ var chainFreezerTableConfigs = map[string]freezerTableConfig{
ChainFreezerReceiptTable: {noSnappy: false, prunable: true}, ChainFreezerReceiptTable: {noSnappy: false, prunable: true},
} }
// freezerTableConfig contains the settings for a freezer table.
type freezerTableConfig struct { type freezerTableConfig struct {
noSnappy bool // disables item compression noSnappy bool // disables item compression
prunable bool // true for tables that can be pruned by TruncateTail prunable bool // true for tables that can be pruned by TruncateTail
@ -63,7 +66,7 @@ const (
stateHistoryStorageData = "storage.data" stateHistoryStorageData = "storage.data"
) )
// stateFreezerTableConfigs configures whether compression is disabled for the state freezer. // stateFreezerTableConfigs configures the settings for tables in the state freezer.
var stateFreezerTableConfigs = map[string]freezerTableConfig{ var stateFreezerTableConfigs = map[string]freezerTableConfig{
stateHistoryMeta: {noSnappy: true, prunable: true}, stateHistoryMeta: {noSnappy: true, prunable: true},
stateHistoryAccountIndex: {noSnappy: false, prunable: true}, stateHistoryAccountIndex: {noSnappy: false, prunable: true},

View file

@ -301,9 +301,8 @@ func (f *Freezer) TruncateHead(items uint64) (uint64, error) {
return oitems, nil return oitems, nil
} }
// TruncateTail discards all data below the provided threshold number // TruncateTail discards all data below the specified threshold. Note that only
// Note this will only truncate 'prunable' tables. Block headers and canonical // 'prunable' tables will be truncated.
// hashes cannot be truncated at this time.
func (f *Freezer) TruncateTail(tail uint64) (uint64, error) { func (f *Freezer) TruncateTail(tail uint64) (uint64, error) {
if f.readonly { if f.readonly {
return 0, errReadOnly return 0, errReadOnly

View file

@ -129,8 +129,7 @@ type AncientWriter interface {
// immediately, but only when the accumulated deleted data reach the threshold then // immediately, but only when the accumulated deleted data reach the threshold then
// will be removed all together. // will be removed all together.
// //
// Note this will only truncate 'prunable' tables. Block headers and canonical // Note that data marked as non-prunable will still be retained and remain accessible.
// hashes cannot be truncated at this time.
TruncateTail(n uint64) (uint64, error) TruncateTail(n uint64) (uint64, error)
// Sync flushes all in-memory ancient store data to disk. // Sync flushes all in-memory ancient store data to disk.