Skip to content

Commit

Permalink
swarm/storage: remove unused methods from Chunk interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeletier committed Dec 11, 2018
1 parent 1e190a3 commit 08073e9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
5 changes: 3 additions & 2 deletions swarm/storage/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion swarm/storage/memstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 0 additions & 18 deletions swarm/storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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))
Expand Down

0 comments on commit 08073e9

Please sign in to comment.