swarm/storage: Add parametric store limits for localdpa + chunksize

const
This commit is contained in:
lash 2017-11-28 19:10:41 +01:00
parent 4a923691e7
commit fe2f4ba2d6
2 changed files with 15 additions and 4 deletions

View file

@ -63,20 +63,27 @@ type DPA struct {
} }
// for testing locally // for testing locally
func NewLocalDPA(datadir string, hashalgorithm string) (*DPA, error) { func NewLocalDPA(datadir string, hashalgorithm string, dbcapacity uint64, memcapacity uint) (*DPA, error) {
if hashalgorithm == "" { if hashalgorithm == "" {
hashalgorithm = "SHA3" hashalgorithm = "SHA3"
} }
hash := MakeHashFunc(hashalgorithm) hash := MakeHashFunc(hashalgorithm)
dbStore, err := NewDbStore(datadir, hash, singletonSwarmDbCapacity, 0) if dbcapacity == 0 {
dbcapacity = uint64(singletonSwarmDbCapacity)
}
if memcapacity == 0 {
memcapacity = uint(singletonSwarmCacheCapacity)
}
log.Debug("LocalDPA create", "dbcap", dbcapacity, "memcap", memcapacity)
dbStore, err := NewDbStore(datadir, hash, dbcapacity, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return NewDPA(&LocalStore{ return NewDPA(&LocalStore{
NewMemStore(dbStore, singletonSwarmCacheCapacity), NewMemStore(dbStore, memcapacity),
dbStore, dbStore,
}, NewChunkerParams()), nil }, NewChunkerParams()), nil
} }

View file

@ -29,6 +29,10 @@ import (
"github.com/ethereum/go-ethereum/crypto/sha3" "github.com/ethereum/go-ethereum/crypto/sha3"
) )
const (
CHUNKSIZE = 4096
)
type Hasher func() hash.Hash type Hasher func() hash.Hash
type SwarmHasher func() SwarmHash type SwarmHasher func() SwarmHash