Documentation ¶
Index ¶
- Constants
- Variables
- func CheckHashConsistency(tree *Tree)
- func CompareTreeNodes(treeA, treeB *Tree)
- func CompareTreeTwigs(treeA, treeB *Tree)
- func CompareTwig(twigID int64, a, b *Twig)
- func EdgeNodesToBytes(edgeNodes []*EdgeNode) []byte
- func EntryToBytes(entry Entry, deactivedSerialNumList []int64) []byte
- func ExtractKeyFromRawBytes(b []byte) []byte
- func ExtractSerialNum(entryBz []byte) int64
- func GetUint24(b []byte) (n uint32)
- func ParrallelRun(workerCount int, fn func(workerID int))
- func PutUint24(b []byte, n uint32)
- func SNListToBytes(deactivedSerialNumList []int64) []byte
- func UpdateSerialNum(entryBz []byte, sn int64)
- type EdgeNode
- type Entry
- type EntryFile
- func (ef *EntryFile) Append(b [2][]byte) (pos int64)
- func (ef *EntryFile) Close()
- func (ef *EntryFile) Flush()
- func (ef *EntryFile) FlushAsync()
- func (ef *EntryFile) GetActiveEntriesInTwig(twig *Twig) chan []byte
- func (ef *EntryFile) PruneHead(off int64)
- func (ef *EntryFile) ReadEntry(off int64) (entry *Entry, nextPos int64)
- func (ef *EntryFile) ReadEntryAndSNList(off int64) (entry *Entry, deactivedSerialNumList []int64, nextPos int64)
- func (ef *EntryFile) ReadEntryRawBytes(off int64) (entryBz []byte, nextPos int64)
- func (ef *EntryFile) Size() int64
- func (ef *EntryFile) Truncate(size int64)
- type HPFile
- func (hpf *HPFile) Append(bufList [][]byte) (int64, error)
- func (hpf *HPFile) Close() error
- func (hpf *HPFile) Flush()
- func (hpf *HPFile) FlushAsync()
- func (hpf *HPFile) InitPreReader()
- func (hpf *HPFile) PruneHead(off int64) error
- func (hpf *HPFile) ReadAt(buf []byte, off int64, withBuf bool) (err error)
- func (hpf *HPFile) Size() int64
- func (hpf *HPFile) Truncate(size int64) error
- type Hasher
- type MockDataTree
- func (dt *MockDataTree) AppendEntry(entry *Entry) int64
- func (dt *MockDataTree) AppendEntryRawBytes(entryBz []byte, sn int64) int64
- func (dt *MockDataTree) Close()
- func (dt *MockDataTree) DeactiviateEntry(sn int64) int
- func (dt *MockDataTree) EndBlock() []byte
- func (dt *MockDataTree) EvictTwig(twigID int64)
- func (dt *MockDataTree) Flush()
- func (dt *MockDataTree) GetActiveBit(sn int64) bool
- func (dt *MockDataTree) GetActiveEntriesInTwig(twigID int64) chan []byte
- func (dt *MockDataTree) GetFileSizes() (int64, int64)
- func (dt *MockDataTree) PruneTwigs(startID, endID int64) []byte
- func (dt *MockDataTree) ReadEntry(pos int64) *Entry
- func (dt *MockDataTree) ScanEntries(oldestActiveTwigID int64, outChan chan types.EntryX)
- func (dt *MockDataTree) ScanEntriesLite(oldestActiveTwigID int64, outChan chan types.KeyAndPos)
- func (dt *MockDataTree) TwigCanBePruned(twigID int64) bool
- type MockTwig
- type NodePos
- type PreReader
- type ProofNode
- type ProofPath
- type Tree
- func (tree *Tree) ActiviateEntry(sn int64)
- func (tree *Tree) AppendEntry(entry *Entry) int64
- func (tree *Tree) AppendEntryRawBytes(entryBz []byte, sn int64) int64
- func (tree *Tree) Close()
- func (tree *Tree) DeactiviateEntry(sn int64) int
- func (tree *Tree) DumpMtree4YT(outfile io.Writer) error
- func (tree *Tree) DumpNodes(outfile io.Writer) error
- func (tree *Tree) EndBlock() (rootHash []byte)
- func (tree *Tree) EvictTwig(twigID int64)
- func (tree *Tree) Flush()
- func (tree *Tree) GetActiveBit(sn int64) bool
- func (tree *Tree) GetActiveEntriesInTwig(twigID int64) chan []byte
- func (tree *Tree) GetFileSizes() (int64, int64)
- func (tree *Tree) GetProof(sn int64) *ProofPath
- func (tree *Tree) LoadMtree4YT(infile io.Reader) error
- func (tree *Tree) LoadNodes(infile io.Reader) error
- func (tree *Tree) PruneTwigs(startID, endID int64) []byte
- func (tree *Tree) ReadEntry(pos int64) (entry *Entry)
- func (tree *Tree) ReapNodes(start, end int64) []byte
- func (tree *Tree) RecoverActiveTwigs(oldestActiveTwigID int64) []int64
- func (tree *Tree) RecoverEntry(pos int64, entry *Entry, deactivedSNList []int64, oldestActiveTwigID int64)
- func (tree *Tree) RecoverInactiveTwigRoots(lastPrunedTwigID, oldestActiveTwigID int64) (newList []int64)
- func (tree *Tree) RecoverUpperNodes(edgeNodes []*EdgeNode, nList []int64)
- func (tree *Tree) ScanEntries(oldestActiveTwigID int64, outChan chan types.EntryX)
- func (tree *Tree) ScanEntriesLite(oldestActiveTwigID int64, outChan chan types.KeyAndPos)
- func (tree *Tree) TruncateFiles(entryFileSize, twigMtFileSize int64)
- func (tree *Tree) TwigCanBePruned(twigID int64) bool
- type Twig
- type TwigMtFile
- func (tf *TwigMtFile) AppendTwig(mtree [][32]byte, firstEntryPos int64)
- func (tf *TwigMtFile) Close()
- func (tf *TwigMtFile) Flush()
- func (tf *TwigMtFile) FlushAsync()
- func (tf *TwigMtFile) GetFirstEntryPos(twigID int64) int64
- func (tf *TwigMtFile) GetHashNode(twigID int64, hashID int) []byte
- func (tf *TwigMtFile) PruneHead(off int64)
- func (tf *TwigMtFile) Size() int64
- func (tf *TwigMtFile) Truncate(size int64)
Constants ¶
View Source
const ( MinimumJobsInGoroutine = 20 MaximumGoroutines = 16 )
View Source
const ( BufferSize = 16 * 1024 * 1024 SmallBufferSize = 32 * 1024 //For UnitTest PreReadBufSize = 256 * 1024 )
View Source
const ( FirstLevelAboveTwig int = 13 MinPruneCount int64 = 2 DeactivedSNListMaxLen = 64 )
View Source
const ( TwigShift = 11 LeafCountInTwig = 1 << TwigShift // 2048 TwigMask = LeafCountInTwig - 1 )
View Source
const Debug = false
var Debug bool
View Source
const (
MSB32 = uint32(1 << 31)
)
View Source
const MaxEntryBytes int = (1 << 24) - 1
View Source
const OtherNodeCount = 1 + 11 + 1 + 3 + 1
View Source
const TwigMtEntryCount = 4095
View Source
const TwigMtSize = 12 + TwigMtEntryCount*32
Variables ¶
View Source
var MagicBytes = [8]byte{255, 254, 253, 252, 252, 253, 254, 255}
View Source
var NullMT4Twig [4096][32]byte
View Source
var NullNodeInHigherTree [64][32]byte
View Source
var Phase1Time, Phase2Time, Phase3Time uint64
View Source
var TotalWriteTime, TotalReadTime, TotalSyncTime uint64
Functions ¶
func CheckHashConsistency ¶
func CheckHashConsistency(tree *Tree)
func CompareTreeNodes ¶
func CompareTreeNodes(treeA, treeB *Tree)
func CompareTreeTwigs ¶
func CompareTreeTwigs(treeA, treeB *Tree)
func CompareTwig ¶
func EdgeNodesToBytes ¶
func EntryToBytes ¶
func ExtractKeyFromRawBytes ¶
func ExtractSerialNum ¶
func ParrallelRun ¶
func SNListToBytes ¶
func UpdateSerialNum ¶
Types ¶
type EdgeNode ¶
func BytesToEdgeNodes ¶
type EntryFile ¶
type EntryFile struct {
HPFile
}
func NewEntryFile ¶
func (*EntryFile) FlushAsync ¶
func (ef *EntryFile) FlushAsync()
func (*EntryFile) GetActiveEntriesInTwig ¶
func (*EntryFile) ReadEntryAndSNList ¶
func (*EntryFile) ReadEntryRawBytes ¶
type HPFile ¶
type HPFile struct {
// contains filtered or unexported fields
}
Head prune-able file
func (*HPFile) FlushAsync ¶
func (hpf *HPFile) FlushAsync()
func (*HPFile) InitPreReader ¶
func (hpf *HPFile) InitPreReader()
type MockDataTree ¶
type MockDataTree struct {
// contains filtered or unexported fields
}
func NewMockDataTree ¶
func NewMockDataTree() *MockDataTree
func (*MockDataTree) AppendEntry ¶
func (dt *MockDataTree) AppendEntry(entry *Entry) int64
func (*MockDataTree) AppendEntryRawBytes ¶
func (dt *MockDataTree) AppendEntryRawBytes(entryBz []byte, sn int64) int64
func (*MockDataTree) Close ¶
func (dt *MockDataTree) Close()
func (*MockDataTree) DeactiviateEntry ¶
func (dt *MockDataTree) DeactiviateEntry(sn int64) int
func (*MockDataTree) EndBlock ¶
func (dt *MockDataTree) EndBlock() []byte
func (*MockDataTree) EvictTwig ¶
func (dt *MockDataTree) EvictTwig(twigID int64)
func (*MockDataTree) Flush ¶
func (dt *MockDataTree) Flush()
func (*MockDataTree) GetActiveBit ¶
func (dt *MockDataTree) GetActiveBit(sn int64) bool
func (*MockDataTree) GetActiveEntriesInTwig ¶
func (dt *MockDataTree) GetActiveEntriesInTwig(twigID int64) chan []byte
func (*MockDataTree) GetFileSizes ¶
func (dt *MockDataTree) GetFileSizes() (int64, int64)
func (*MockDataTree) PruneTwigs ¶
func (dt *MockDataTree) PruneTwigs(startID, endID int64) []byte
func (*MockDataTree) ReadEntry ¶
func (dt *MockDataTree) ReadEntry(pos int64) *Entry
func (*MockDataTree) ScanEntries ¶
func (dt *MockDataTree) ScanEntries(oldestActiveTwigID int64, outChan chan types.EntryX)
func (*MockDataTree) ScanEntriesLite ¶
func (dt *MockDataTree) ScanEntriesLite(oldestActiveTwigID int64, outChan chan types.KeyAndPos)
func (*MockDataTree) TwigCanBePruned ¶
func (dt *MockDataTree) TwigCanBePruned(twigID int64) bool
type ProofPath ¶
type ProofPath struct { LeftOfTwig [11]ProofNode RightOfTwig [3]ProofNode UpperPath []ProofNode SerialNum int64 Root [32]byte }
func BytesToProofPath ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func NewEmptyTree ¶
func RecoverTree ¶
func (*Tree) ActiviateEntry ¶
func (*Tree) AppendEntry ¶
func (*Tree) AppendEntryRawBytes ¶
func (*Tree) DeactiviateEntry ¶
func (*Tree) GetActiveBit ¶
func (*Tree) GetActiveEntriesInTwig ¶
func (*Tree) GetFileSizes ¶
func (*Tree) PruneTwigs ¶
Prune the twigs between startID and endID
func (*Tree) RecoverActiveTwigs ¶
func (*Tree) RecoverEntry ¶
func (*Tree) RecoverInactiveTwigRoots ¶
func (*Tree) RecoverUpperNodes ¶
func (*Tree) ScanEntries ¶
func (*Tree) ScanEntriesLite ¶
func (*Tree) TruncateFiles ¶
func (*Tree) TwigCanBePruned ¶
type Twig ¶
type Twig struct { FirstEntryPos int64 // contains filtered or unexported fields }
var NullTwig Twig
func CopyNullTwig ¶
func CopyNullTwig() *Twig
func LoadTwigFromFile ¶
type TwigMtFile ¶
type TwigMtFile struct {
HPFile
}
func NewTwigMtFile ¶
func NewTwigMtFile(bufferSize, blockSize int, dirName string) (res TwigMtFile, err error)
func (*TwigMtFile) AppendTwig ¶
func (tf *TwigMtFile) AppendTwig(mtree [][32]byte, firstEntryPos int64)
func (*TwigMtFile) Close ¶
func (tf *TwigMtFile) Close()
func (*TwigMtFile) Flush ¶
func (tf *TwigMtFile) Flush()
func (*TwigMtFile) FlushAsync ¶
func (tf *TwigMtFile) FlushAsync()
func (*TwigMtFile) GetFirstEntryPos ¶
func (tf *TwigMtFile) GetFirstEntryPos(twigID int64) int64
func (*TwigMtFile) GetHashNode ¶
func (tf *TwigMtFile) GetHashNode(twigID int64, hashID int) []byte
func (*TwigMtFile) PruneHead ¶
func (tf *TwigMtFile) PruneHead(off int64)
func (*TwigMtFile) Size ¶
func (tf *TwigMtFile) Size() int64
func (*TwigMtFile) Truncate ¶
func (tf *TwigMtFile) Truncate(size int64)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.