Skip to content

Commit fe86a70

Browse files
jpeletiernonsense
authored andcommitted
swarm/storage: remove unused methods from Chunk interface (#18283)
1 parent b01cfce commit fe86a70

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

swarm/storage/common_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ func testStoreCorrect(m ChunkStore, n int, chunksize int64, t *testing.T) {
179179
return fmt.Errorf("key does not match retrieved chunk Address")
180180
}
181181
hasher := MakeHashFunc(DefaultHash)()
182-
hasher.ResetWithLength(chunk.SpanBytes())
183-
hasher.Write(chunk.Payload())
182+
data := chunk.Data()
183+
hasher.ResetWithLength(data[:8])
184+
hasher.Write(data[8:])
184185
exp := hasher.Sum(nil)
185186
if !bytes.Equal(h, exp) {
186187
return fmt.Errorf("key is not hash of chunk data")

swarm/storage/memstore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (m *MemStore) Get(_ context.Context, addr Address) (Chunk, error) {
5757
if !ok {
5858
return nil, ErrChunkNotFound
5959
}
60-
return c.(*chunk), nil
60+
return c.(Chunk), nil
6161
}
6262

6363
func (m *MemStore) Put(_ context.Context, c Chunk) error {

swarm/storage/types.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ func (c AddressCollection) Swap(i, j int) {
184184
// Chunk interface implemented by context.Contexts and data chunks
185185
type Chunk interface {
186186
Address() Address
187-
Payload() []byte
188-
SpanBytes() []byte
189-
Span() int64
190187
Data() []byte
191188
}
192189

@@ -208,25 +205,10 @@ func (c *chunk) Address() Address {
208205
return c.addr
209206
}
210207

211-
func (c *chunk) SpanBytes() []byte {
212-
return c.sdata[:8]
213-
}
214-
215-
func (c *chunk) Span() int64 {
216-
if c.span == -1 {
217-
c.span = int64(binary.LittleEndian.Uint64(c.sdata[:8]))
218-
}
219-
return c.span
220-
}
221-
222208
func (c *chunk) Data() []byte {
223209
return c.sdata
224210
}
225211

226-
func (c *chunk) Payload() []byte {
227-
return c.sdata[8:]
228-
}
229-
230212
// String() for pretty printing
231213
func (self *chunk) String() string {
232214
return fmt.Sprintf("Address: %v TreeSize: %v Chunksize: %v", self.addr.Log(), self.span, len(self.sdata))

0 commit comments

Comments
 (0)