aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/storage/types.go
diff options
context:
space:
mode:
authorZahoor Mohamed <zahoor@zahoor.in>2017-09-22 04:22:51 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-09-22 04:22:51 +0800
commitd558a595adf4e89bab5b28ffde1448dc1e5768b0 (patch)
tree1316cca927bfd4dfc4a8673ae0b9c2f75724f07e /swarm/storage/types.go
parent3c8656347f67dbc8e57c663ec5c26d24c4151678 (diff)
downloadgo-tangerine-d558a595adf4e89bab5b28ffde1448dc1e5768b0.tar
go-tangerine-d558a595adf4e89bab5b28ffde1448dc1e5768b0.tar.gz
go-tangerine-d558a595adf4e89bab5b28ffde1448dc1e5768b0.tar.bz2
go-tangerine-d558a595adf4e89bab5b28ffde1448dc1e5768b0.tar.lz
go-tangerine-d558a595adf4e89bab5b28ffde1448dc1e5768b0.tar.xz
go-tangerine-d558a595adf4e89bab5b28ffde1448dc1e5768b0.tar.zst
go-tangerine-d558a595adf4e89bab5b28ffde1448dc1e5768b0.zip
swarm/storage: pyramid chunker re-write (#14382)
Diffstat (limited to 'swarm/storage/types.go')
-rw-r--r--swarm/storage/types.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/swarm/storage/types.go b/swarm/storage/types.go
index a9de23c93..d35f1f929 100644
--- a/swarm/storage/types.go
+++ b/swarm/storage/types.go
@@ -24,12 +24,13 @@ import (
"io"
"sync"
- // "github.com/ethereum/go-ethereum/bmt"
+ "github.com/ethereum/go-ethereum/bmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/sha3"
)
type Hasher func() hash.Hash
+type SwarmHasher func() SwarmHash
// Peer is the recorded as Source on the chunk
// should probably not be here? but network should wrap chunk object
@@ -78,12 +79,18 @@ func IsZeroKey(key Key) bool {
var ZeroKey = Key(common.Hash{}.Bytes())
-func MakeHashFunc(hash string) Hasher {
+func MakeHashFunc(hash string) SwarmHasher {
switch hash {
case "SHA256":
- return crypto.SHA256.New
+ return func() SwarmHash { return &HashWithLength{crypto.SHA256.New()} }
case "SHA3":
- return sha3.NewKeccak256
+ return func() SwarmHash { return &HashWithLength{sha3.NewKeccak256()} }
+ case "BMT":
+ return func() SwarmHash {
+ hasher := sha3.NewKeccak256
+ pool := bmt.NewTreePool(hasher, bmt.DefaultSegmentCount, bmt.DefaultPoolSize)
+ return bmt.New(pool)
+ }
}
return nil
}
@@ -192,6 +199,13 @@ type Splitter interface {
A closed error signals process completion at which point the key can be considered final if there were no errors.
*/
Split(io.Reader, int64, chan *Chunk, *sync.WaitGroup, *sync.WaitGroup) (Key, error)
+
+ /* This is the first step in making files mutable (not chunks)..
+ Append allows adding more data chunks to the end of the already existsing file.
+ The key for the root chunk is supplied to load the respective tree.
+ Rest of the parameters behave like Split.
+ */
+ Append(Key, io.Reader, chan *Chunk, *sync.WaitGroup, *sync.WaitGroup) (Key, error)
}
type Joiner interface {