diff options
author | Javier Peletier <jpeletier@users.noreply.github.com> | 2018-12-18 22:25:02 +0800 |
---|---|---|
committer | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-12-18 22:25:02 +0800 |
commit | fe86a707d8270108e0fb77359e702689664dcb4b (patch) | |
tree | 495c3b10b4e5c0593ba3ee582f1d43c16f54db74 | |
parent | b01cfce36276379a95deb1001a6f1b6a048609de (diff) | |
download | go-tangerine-fe86a707d8270108e0fb77359e702689664dcb4b.tar go-tangerine-fe86a707d8270108e0fb77359e702689664dcb4b.tar.gz go-tangerine-fe86a707d8270108e0fb77359e702689664dcb4b.tar.bz2 go-tangerine-fe86a707d8270108e0fb77359e702689664dcb4b.tar.lz go-tangerine-fe86a707d8270108e0fb77359e702689664dcb4b.tar.xz go-tangerine-fe86a707d8270108e0fb77359e702689664dcb4b.tar.zst go-tangerine-fe86a707d8270108e0fb77359e702689664dcb4b.zip |
swarm/storage: remove unused methods from Chunk interface (#18283)
-rw-r--r-- | swarm/storage/common_test.go | 5 | ||||
-rw-r--r-- | swarm/storage/memstore.go | 2 | ||||
-rw-r--r-- | swarm/storage/types.go | 18 |
3 files changed, 4 insertions, 21 deletions
diff --git a/swarm/storage/common_test.go b/swarm/storage/common_test.go index af104a5ae..bcc29d8cc 100644 --- a/swarm/storage/common_test.go +++ b/swarm/storage/common_test.go @@ -179,8 +179,9 @@ func testStoreCorrect(m ChunkStore, n int, chunksize int64, t *testing.T) { return fmt.Errorf("key does not match retrieved chunk Address") } hasher := MakeHashFunc(DefaultHash)() - hasher.ResetWithLength(chunk.SpanBytes()) - hasher.Write(chunk.Payload()) + data := chunk.Data() + hasher.ResetWithLength(data[:8]) + hasher.Write(data[8:]) exp := hasher.Sum(nil) if !bytes.Equal(h, exp) { return fmt.Errorf("key is not hash of chunk data") diff --git a/swarm/storage/memstore.go b/swarm/storage/memstore.go index 36b1e00d9..86e5813d1 100644 --- a/swarm/storage/memstore.go +++ b/swarm/storage/memstore.go @@ -57,7 +57,7 @@ func (m *MemStore) Get(_ context.Context, addr Address) (Chunk, error) { if !ok { return nil, ErrChunkNotFound } - return c.(*chunk), nil + return c.(Chunk), nil } func (m *MemStore) Put(_ context.Context, c Chunk) error { diff --git a/swarm/storage/types.go b/swarm/storage/types.go index e5c5f89a0..322d95c47 100644 --- a/swarm/storage/types.go +++ b/swarm/storage/types.go @@ -184,9 +184,6 @@ func (c AddressCollection) Swap(i, j int) { // Chunk interface implemented by context.Contexts and data chunks type Chunk interface { Address() Address - Payload() []byte - SpanBytes() []byte - Span() int64 Data() []byte } @@ -208,25 +205,10 @@ func (c *chunk) Address() Address { return c.addr } -func (c *chunk) SpanBytes() []byte { - return c.sdata[:8] -} - -func (c *chunk) Span() int64 { - if c.span == -1 { - c.span = int64(binary.LittleEndian.Uint64(c.sdata[:8])) - } - return c.span -} - func (c *chunk) Data() []byte { return c.sdata } -func (c *chunk) Payload() []byte { - return c.sdata[8:] -} - // String() for pretty printing func (self *chunk) String() string { return fmt.Sprintf("Address: %v TreeSize: %v Chunksize: %v", self.addr.Log(), self.span, len(self.sdata)) |