Add new localStore constructor for tests

This commit is contained in:
Balint Gabor 2018-01-12 09:50:53 +01:00
parent debf3f6932
commit c0c45e3825

View file

@ -42,6 +42,20 @@ func NewLocalStore(hash SwarmHasher, params *StoreParams, basekey []byte) (*Loca
}, nil }, nil
} }
func NewTestLocalStore(path string) (*LocalStore, error) {
basekey := make([]byte, 32)
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) {