Commit e207becb authored by acud's avatar acud Committed by GitHub

pipeline: adjust signature to take in Putter instead of Storer (#861)

parent 5c657db7
......@@ -21,7 +21,7 @@ import (
)
// NewPipelineBuilder returns the appropriate pipeline according to the specified parameters
func NewPipelineBuilder(ctx context.Context, s storage.Storer, mode storage.ModePut, encrypt bool) pipeline.Interface {
func NewPipelineBuilder(ctx context.Context, s storage.Putter, mode storage.ModePut, encrypt bool) pipeline.Interface {
if encrypt {
return newEncryptionPipeline(ctx, s, mode)
}
......@@ -31,7 +31,7 @@ func NewPipelineBuilder(ctx context.Context, s storage.Storer, mode storage.Mode
// newPipeline creates a standard pipeline that only hashes content with BMT to create
// a merkle-tree of hashes that represent the given arbitrary size byte stream. Partial
// writes are supported. The pipeline flow is: Data -> Feeder -> BMT -> Storage -> HashTrie.
func newPipeline(ctx context.Context, s storage.Storer, mode storage.ModePut) pipeline.Interface {
func newPipeline(ctx context.Context, s storage.Putter, mode storage.ModePut) pipeline.Interface {
tw := hashtrie.NewHashTrieWriter(swarm.ChunkSize, swarm.Branches, swarm.HashSize, newShortPipelineFunc(ctx, s, mode))
lsw := store.NewStoreWriter(ctx, s, mode, tw)
b := bmt.NewBmtWriter(lsw)
......@@ -40,7 +40,7 @@ func newPipeline(ctx context.Context, s storage.Storer, mode storage.ModePut) pi
// newShortPipelineFunc returns a constructor function for an ephemeral hashing pipeline
// needed by the hashTrieWriter.
func newShortPipelineFunc(ctx context.Context, s storage.Storer, mode storage.ModePut) func() pipeline.ChainWriter {
func newShortPipelineFunc(ctx context.Context, s storage.Putter, mode storage.ModePut) func() pipeline.ChainWriter {
return func() pipeline.ChainWriter {
lsw := store.NewStoreWriter(ctx, s, mode, nil)
return bmt.NewBmtWriter(lsw)
......@@ -52,7 +52,7 @@ func newShortPipelineFunc(ctx context.Context, s storage.Storer, mode storage.Mo
// writes are supported. The pipeline flow is: Data -> Feeder -> Encryption -> BMT -> Storage -> HashTrie.
// Note that the encryption writer will mutate the data to contain the encrypted span, but the span field
// with the unencrypted span is preserved.
func newEncryptionPipeline(ctx context.Context, s storage.Storer, mode storage.ModePut) pipeline.Interface {
func newEncryptionPipeline(ctx context.Context, s storage.Putter, mode storage.ModePut) pipeline.Interface {
tw := hashtrie.NewHashTrieWriter(swarm.ChunkSize, 64, swarm.HashSize+encryption.KeyLength, newShortEncryptionPipelineFunc(ctx, s, mode))
lsw := store.NewStoreWriter(ctx, s, mode, tw)
b := bmt.NewBmtWriter(lsw)
......@@ -62,7 +62,7 @@ func newEncryptionPipeline(ctx context.Context, s storage.Storer, mode storage.M
// newShortEncryptionPipelineFunc returns a constructor function for an ephemeral hashing pipeline
// needed by the hashTrieWriter.
func newShortEncryptionPipelineFunc(ctx context.Context, s storage.Storer, mode storage.ModePut) func() pipeline.ChainWriter {
func newShortEncryptionPipelineFunc(ctx context.Context, s storage.Putter, mode storage.ModePut) func() pipeline.ChainWriter {
return func() pipeline.ChainWriter {
lsw := store.NewStoreWriter(ctx, s, mode, nil)
b := bmt.NewBmtWriter(lsw)
......
......@@ -25,7 +25,7 @@ type storeWriter struct {
}
// NewStoreWriter returns a storeWriter. It just writes the given data
// to a given storage.Storer.
// to a given storage.Putter.
func NewStoreWriter(ctx context.Context, l storage.Putter, mode storage.ModePut, next pipeline.ChainWriter) pipeline.ChainWriter {
return &storeWriter{ctx: ctx, l: l, mode: mode, next: next}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment