github.com/theQRL/go-zond@v0.2.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 36 // chainFreezerNoSnappy configures whether compression is disabled for the ancient-tables. 37 // Hashes don't compress well. 38 var chainFreezerNoSnappy = map[string]bool{ 39 ChainFreezerHeaderTable: false, 40 ChainFreezerHashTable: true, 41 ChainFreezerBodiesTable: false, 42 ChainFreezerReceiptTable: false, 43 } 44 45 const ( 46 // stateHistoryTableSize defines the maximum size of freezer data files. 47 stateHistoryTableSize = 2 * 1000 * 1000 * 1000 48 49 // stateHistoryAccountIndex indicates the name of the freezer state history table. 50 stateHistoryMeta = "history.meta" 51 stateHistoryAccountIndex = "account.index" 52 stateHistoryStorageIndex = "storage.index" 53 stateHistoryAccountData = "account.data" 54 stateHistoryStorageData = "storage.data" 55 ) 56 57 var stateFreezerNoSnappy = map[string]bool{ 58 stateHistoryMeta: true, 59 stateHistoryAccountIndex: false, 60 stateHistoryStorageIndex: false, 61 stateHistoryAccountData: false, 62 stateHistoryStorageData: false, 63 } 64 65 // The list of identifiers of ancient stores. 66 var ( 67 chainFreezerName = "chain" // the folder name of chain segment ancient store. 68 stateFreezerName = "state" // the folder name of reverse diff ancient store. 69 ) 70 71 // freezers the collections of all builtin freezers. 72 var freezers = []string{chainFreezerName, stateFreezerName} 73 74 // NewStateFreezer initializes the freezer for state history. 75 func NewStateFreezer(ancientDir string, readOnly bool) (*ResettableFreezer, error) { 76 return NewResettableFreezer(filepath.Join(ancientDir, stateFreezerName), "eth/db/state", readOnly, stateHistoryTableSize, stateFreezerNoSnappy) 77 }