mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
swarm/storage: NewLocalStoreFromAddr and set bucketCnt to access index
This commit is contained in:
parent
365bd3b6d2
commit
22b4959709
2 changed files with 15 additions and 1 deletions
|
|
@ -542,10 +542,11 @@ func (s *DbStore) doPut(chunk *Chunk, ikey []byte, index *dpaDBIndex, po uint8)
|
||||||
data := encodeData(chunk)
|
data := encodeData(chunk)
|
||||||
s.batch.Put(getDataKey(s.dataIdx, po), data)
|
s.batch.Put(getDataKey(s.dataIdx, po), data)
|
||||||
index.Idx = s.dataIdx
|
index.Idx = s.dataIdx
|
||||||
|
s.bucketCnt[po] = s.dataIdx
|
||||||
s.entryCnt++
|
s.entryCnt++
|
||||||
s.dataIdx++
|
s.dataIdx++
|
||||||
|
|
||||||
s.bucketCnt[po]++
|
// s.bucketCnt[po]++
|
||||||
cntKey := make([]byte, 2)
|
cntKey := make([]byte, 2)
|
||||||
cntKey[0] = keyDistanceCnt
|
cntKey[0] = keyDistanceCnt
|
||||||
cntKey[1] = po
|
cntKey[1] = po
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,19 @@ func NewTestLocalStore(path string) (*LocalStore, error) {
|
||||||
return localStore, nil
|
return localStore, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewTestLocalStoreForAddr(path string, basekey []byte) (*LocalStore, error) {
|
||||||
|
hasher := MakeHashFunc("SHA3")
|
||||||
|
dbStore, err := NewDbStore(path, hasher, singletonSwarmDbCapacity, func(k Key) (ret uint8) { return uint8(Proximity(basekey[:], k[:])) })
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
localStore := &LocalStore{
|
||||||
|
memStore: NewMemStore(dbStore, singletonSwarmDbCapacity),
|
||||||
|
DbStore: dbStore,
|
||||||
|
}
|
||||||
|
return localStore, nil
|
||||||
|
}
|
||||||
|
|
||||||
// LocalStore is itself a chunk store
|
// LocalStore is itself a chunk store
|
||||||
// unsafe, in that the data is not integrity checked
|
// unsafe, in that the data is not integrity checked
|
||||||
func (self *LocalStore) Put(chunk *Chunk) {
|
func (self *LocalStore) Put(chunk *Chunk) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue