Created
April 2, 2019 12:41
-
-
Save ackratos/426026150fef44fb5eac7885c3769f9c to your computer and use it in GitHub Desktop.
snapshot.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package types | |
import "fmt" | |
const ManifestVersion int32 = 0 | |
type SHA256Sum [32]byte // check sum of chunk | |
func (hsum SHA256Sum) String() string { | |
return fmt.Sprintf("%X", hsum) | |
} | |
type Manifest struct { | |
Version int32 // snapshot Version | |
Height int64 // the height of this snapshot | |
StateHashes []SHA256Sum // hashes of state chunks | |
AppStateHashes []SHA256Sum // hashes of app state chunks | |
BlockHashes []SHA256Sum // Block hashes | |
NumKeys []int64 // num of keys for each substore, this sacrifices clear boundary between cosmos and tendermint, saying tendermint knows applicaction db might organized by substores. But reduce network/disk pressure that each chunk must has a field indicates what's his store | |
} | |
func NewManifest( | |
height int64, | |
stateHashes []SHA256Sum, | |
appStateHashes []SHA256Sum, | |
blockHashes []SHA256Sum, | |
numKeys []int64) Manifest { | |
return Manifest { | |
ManifestVersion, | |
height, | |
stateHashes, | |
appStateHashes, | |
blockHashes, | |
numKeys, | |
} | |
} | |
func (m *Manifest) Serialize() []byte { | |
// encode to amino bytes | |
// snappy compression | |
return nil | |
} | |
type SnapshotChunk interface{} | |
type StateChunk struct { | |
statepart []byte | |
} | |
type AppStateChunk struct { | |
startIdx int64 // compare (startIdx and number of complete nodes) against (Manifest.NumKeys) we know each node's substore | |
complete bool // whether last node in `nodes` is complete, if not we concatenate bytes with following chunks first node | |
nodes [][]byte // iavl tree serialized node, one big node (i.e. active orders and orderbook) might be split into different chunks (complete is flag to indicate that), ordering is ensured by list on manifest | |
} | |
type BlockChunk struct { | |
blockpart []byte | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment