github.com/theQRL/go-zond@v0.1.1/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 "path/filepath" 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 const ( 50 // stateHistoryTableSize defines the maximum size of freezer data files. 51 stateHistoryTableSize = 2 * 1000 * 1000 * 1000 52 53 // stateHistoryAccountIndex indicates the name of the freezer state history table. 54 stateHistoryMeta = "history.meta" 55 stateHistoryAccountIndex = "account.index" 56 stateHistoryStorageIndex = "storage.index" 57 stateHistoryAccountData = "account.data" 58 stateHistoryStorageData = "storage.data" 59 ) 60 61 var stateFreezerNoSnappy = map[string]bool{ 62 stateHistoryMeta: true, 63 stateHistoryAccountIndex: false, 64 stateHistoryStorageIndex: false, 65 stateHistoryAccountData: false, 66 stateHistoryStorageData: false, 67 } 68 69 // The list of identifiers of ancient stores. 70 var ( 71 chainFreezerName = "chain" // the folder name of chain segment ancient store. 72 stateFreezerName = "state" // the folder name of reverse diff ancient store. 73 ) 74 75 // freezers the collections of all builtin freezers. 76 var freezers = []string{chainFreezerName, stateFreezerName} 77 78 // NewStateFreezer initializes the freezer for state history. 79 func NewStateFreezer(ancientDir string, readOnly bool) (*ResettableFreezer, error) { 80 return NewResettableFreezer(filepath.Join(ancientDir, stateFreezerName), "eth/db/state", readOnly, stateHistoryTableSize, stateFreezerNoSnappy) 81 }