mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
started moving logic from bzz-fefe
This commit is contained in:
parent
4ea99e804f
commit
99190409dd
1 changed files with 12 additions and 8 deletions
|
|
@ -7,15 +7,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
maxEntries = 500 // max number of stored (cached) blocks
|
maxEntries = 500 // max number of stored (cached) blocks
|
||||||
memTreeLW = 2 // log2(subtree count) of the subtrees
|
memTreeLW = 2 // log2(subtree count) of the subtrees
|
||||||
memTreeFLW = 14 // log2(subtree count) of the root layer
|
memTreeFLW = 14 // log2(subtree count) of the root layer
|
||||||
|
dbForceUpdateAccessCnt = 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
type dpaMemStorage struct {
|
type dpaMemStorage struct {
|
||||||
memtree *dpaMemTree
|
memtree *dpaMemTree
|
||||||
entry_cnt uint // stored entries
|
entry_cnt uint // stored entries
|
||||||
access_cnt uint64 // access counter; oldest is thrown away when full
|
access_cnt uint64 // access counter; oldest is thrown away when full
|
||||||
|
dbAccessCnt uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -75,8 +77,9 @@ type dpaMemTree struct {
|
||||||
bits uint // log2(subtree count)
|
bits uint // log2(subtree count)
|
||||||
width uint // subtree count
|
width uint // subtree count
|
||||||
|
|
||||||
entry *Chunk // if subtrees are present, entry should be nil
|
entry *Chunk // if subtrees are present, entry should be nil
|
||||||
access []uint64
|
lastDBaccess uint64
|
||||||
|
access []uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTreeNode(b uint, parent *dpaMemTree, pidx uint) (node *dpaMemTree) {
|
func newTreeNode(b uint, parent *dpaMemTree, pidx uint) (node *dpaMemTree) {
|
||||||
|
|
@ -177,6 +180,7 @@ func (s *dpaMemStorage) add(entry *Chunk) {
|
||||||
}
|
}
|
||||||
|
|
||||||
node.entry = entry
|
node.entry = entry
|
||||||
|
node.lastDBaccess = s.dbAccessCnt
|
||||||
node.update_access(s.access_cnt)
|
node.update_access(s.access_cnt)
|
||||||
s.entry_cnt++
|
s.entry_cnt++
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue