github.com/ethw3/go-ethereuma@v0.0.0-20221013053120-c14602a4c23c/core/rawdb/ancient_scheme.go (about) 1 // Copyright 2022 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package rawdb 18 19 import "fmt" 20 21 // The list of table names of chain freezer. 22 const ( 23 // chainFreezerHeaderTable indicates the name of the freezer header table. 24 chainFreezerHeaderTable = "headers" 25 26 // chainFreezerHashTable indicates the name of the freezer canonical hash table. 27 chainFreezerHashTable = "hashes" 28 29 // chainFreezerBodiesTable indicates the name of the freezer block body table. 30 chainFreezerBodiesTable = "bodies" 31 32 // chainFreezerReceiptTable indicates the name of the freezer receipts table. 33 chainFreezerReceiptTable = "receipts" 34 35 // chainFreezerDifficultyTable indicates the name of the freezer total difficulty table. 36 chainFreezerDifficultyTable = "diffs" 37 ) 38 39 // chainFreezerNoSnappy configures whether compression is disabled for the ancient-tables. 40 // Hashes and difficulties don't compress well. 41 var chainFreezerNoSnappy = map[string]bool{ 42 chainFreezerHeaderTable: false, 43 chainFreezerHashTable: true, 44 chainFreezerBodiesTable: false, 45 chainFreezerReceiptTable: false, 46 chainFreezerDifficultyTable: true, 47 } 48 49 // The list of identifiers of ancient stores. 50 var ( 51 chainFreezerName = "chain" // the folder name of chain segment ancient store. 52 ) 53 54 // freezers the collections of all builtin freezers. 55 var freezers = []string{chainFreezerName} 56 57 // InspectFreezerTable dumps out the index of a specific freezer table. The passed 58 // ancient indicates the path of root ancient directory where the chain freezer can 59 // be opened. Start and end specify the range for dumping out indexes. 60 // Note this function can only be used for debugging purposes. 61 func InspectFreezerTable(ancient string, freezerName string, tableName string, start, end int64) error { 62 var ( 63 path string 64 tables map[string]bool 65 ) 66 switch freezerName { 67 case chainFreezerName: 68 path, tables = resolveChainFreezerDir(ancient), chainFreezerNoSnappy 69 default: 70 return fmt.Errorf("unknown freezer, supported ones: %v", freezers) 71 } 72 noSnappy, exist := tables[tableName] 73 if !exist { 74 var names []string 75 for name := range tables { 76 names = append(names, name) 77 } 78 return fmt.Errorf("unknown table, supported ones: %v", names) 79 } 80 table, err := newFreezerTable(path, tableName, noSnappy, true) 81 if err != nil { 82 return err 83 } 84 table.dumpIndexStdout(start, end) 85 return nil 86 }