github.com/klaytn/klaytn@v1.12.1/storage/statedb/doc.go (about) 1 // Copyright 2018 The klaytn Authors 2 // Copyright 2016 The go-ethereum Authors 3 // This file is part of the go-ethereum library. 4 // 5 // The go-ethereum library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-ethereum library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 17 // 18 // This file is derived from ethstats/ethstats.go (2018/06/04). 19 // Modified and improved for the klaytn development. 20 21 /* 22 Package statedb implements the Merkle Patricia Trie structure used for state object trie. 23 This package is used to read/write data from/to the state object trie. 24 25 Overview of statedb package 26 27 There are 3 key struct in this package: Trie, SecureTrie and Database. 28 29 Trie struct represents a Merkle Patricia Trie. 30 31 SecureTrie is a basically same as Trie but it wraps a trie with key hashing. 32 In a SecureTrie, all access operations hash the key using keccak256. 33 This prevents calling code from creating long chains of nodes that increase the access time. 34 35 Database is an intermediate write layer between the trie data structures and 36 the disk database. The aim is to accumulate trie writes in-memory and only 37 periodically flush a couple tries to disk, garbage collecting the remainder. 38 39 40 Source Files 41 42 Related functions and variables are defined in the files listed below 43 - database.go : Implementation of Database struct 44 - db_migration.go : Implementation of DB migration 45 - derive_sha.go : Implementation of DeriveShaOrig used in Klaytn 46 - encoding.go : Implementation of 3 encodings: KEYBYTES, HEX and COMPACT 47 - errors.go : Errors used in this package 48 - hasher.go : Implementation of recursive and bottom-up hashing 49 - iterator.go : Implementation of key-value trie iterator that traverses a Trie 50 - node.go : Implementation of 4 types of nodes, used in Merkle Patricia Trie 51 - proof.go : Functions which construct a Merkle Patricia Proof for the given key 52 - secure_trie.go : Implementation of Merkle Patricia Trie with key hashing 53 - sync.go : Implementation of state trie sync 54 - trie.go : Implementation of Merkle Patricia Trie 55 */ 56 package statedb