mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm/storage: import swarm/chunk with original package name everywhere
This commit is contained in:
parent
62d79bfbf0
commit
d6916a7bec
10 changed files with 57 additions and 60 deletions
|
|
@ -25,7 +25,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/spancontext"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
|
|
@ -127,7 +127,7 @@ type TreeChunker struct {
|
|||
func TreeJoin(ctx context.Context, addr Address, getter Getter, depth int) *LazyChunkReader {
|
||||
jp := &JoinerParams{
|
||||
ChunkerParams: ChunkerParams{
|
||||
chunkSize: ch.DefaultSize,
|
||||
chunkSize: chunk.DefaultSize,
|
||||
hashSize: int64(len(addr)),
|
||||
},
|
||||
addr: addr,
|
||||
|
|
@ -147,7 +147,7 @@ func TreeSplit(ctx context.Context, data io.Reader, size int64, putter Putter) (
|
|||
tsp := &TreeSplitterParams{
|
||||
SplitterParams: SplitterParams{
|
||||
ChunkerParams: ChunkerParams{
|
||||
chunkSize: ch.DefaultSize,
|
||||
chunkSize: chunk.DefaultSize,
|
||||
hashSize: putter.RefSize(),
|
||||
},
|
||||
reader: data,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/mattn/go-colorable"
|
||||
)
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ func mput(store ChunkStore, n int, f func(i int64) Chunk) (hs []Chunk, err error
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
|
||||
defer cancel()
|
||||
for i := int64(0); i < int64(n); i++ {
|
||||
chunk := f(ch.DefaultSize)
|
||||
chunk := f(chunk.DefaultSize)
|
||||
go func() {
|
||||
select {
|
||||
case errc <- store.Put(ctx, chunk):
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
package storage
|
||||
|
||||
import (
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
)
|
||||
import "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
|
||||
const (
|
||||
ErrInit = iota
|
||||
|
|
@ -33,6 +31,6 @@ const (
|
|||
|
||||
// Errors are the same as the ones in chunk package for backward compatibility.
|
||||
var (
|
||||
ErrChunkNotFound = ch.ErrChunkNotFound
|
||||
ErrChunkInvalid = ch.ErrChunkNotFound
|
||||
ErrChunkNotFound = chunk.ErrChunkNotFound
|
||||
ErrChunkInvalid = chunk.ErrChunkNotFound
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import (
|
|||
"fmt"
|
||||
"sync/atomic"
|
||||
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/encryption"
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
|
@ -189,9 +189,9 @@ func (h *hasherStore) decryptChunkData(chunkData ChunkData, encryptionKey encryp
|
|||
|
||||
// removing extra bytes which were just added for padding
|
||||
length := ChunkData(decryptedSpan).Size()
|
||||
for length > ch.DefaultSize {
|
||||
length = length + (ch.DefaultSize - 1)
|
||||
length = length / ch.DefaultSize
|
||||
for length > chunk.DefaultSize {
|
||||
length = length + (chunk.DefaultSize - 1)
|
||||
length = length / chunk.DefaultSize
|
||||
length *= uint64(h.refSize)
|
||||
}
|
||||
|
||||
|
|
@ -232,11 +232,11 @@ func (h *hasherStore) decrypt(chunkData ChunkData, key encryption.Key) ([]byte,
|
|||
}
|
||||
|
||||
func (h *hasherStore) newSpanEncryption(key encryption.Key) encryption.Encryption {
|
||||
return encryption.New(key, 0, uint32(ch.DefaultSize/h.refSize), sha3.NewLegacyKeccak256)
|
||||
return encryption.New(key, 0, uint32(chunk.DefaultSize/h.refSize), sha3.NewLegacyKeccak256)
|
||||
}
|
||||
|
||||
func (h *hasherStore) newDataEncryption(key encryption.Key) encryption.Encryption {
|
||||
return encryption.New(key, int(ch.DefaultSize), 0, sha3.NewLegacyKeccak256)
|
||||
return encryption.New(key, int(chunk.DefaultSize), 0, sha3.NewLegacyKeccak256)
|
||||
}
|
||||
|
||||
func (h *hasherStore) storeChunk(ctx context.Context, chunk Chunk) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mock/mem"
|
||||
ldberrors "github.com/syndtr/goleveldb/leveldb/errors"
|
||||
|
|
@ -103,7 +103,7 @@ func TestMarkAccessed(t *testing.T) {
|
|||
t.Fatalf("init dbStore failed: %v", err)
|
||||
}
|
||||
|
||||
h := GenerateRandomChunk(ch.DefaultSize)
|
||||
h := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
db.Put(context.Background(), h)
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ func testIterator(t *testing.T, mock bool) {
|
|||
t.Fatalf("init dbStore failed: %v", err)
|
||||
}
|
||||
|
||||
chunks := GenerateRandomChunks(ch.DefaultSize, chunkcount)
|
||||
chunks := GenerateRandomChunks(chunk.DefaultSize, chunkcount)
|
||||
|
||||
for i = 0; i < len(chunks); i++ {
|
||||
chunkkeys[i] = chunks[i].Address()
|
||||
|
|
@ -468,7 +468,7 @@ func testLDBStoreRemoveThenCollectGarbage(t *testing.T) {
|
|||
// put capacity count number of chunks
|
||||
chunks := make([]Chunk, n)
|
||||
for i := 0; i < n; i++ {
|
||||
c := GenerateRandomChunk(ch.DefaultSize)
|
||||
c := GenerateRandomChunk(chunk.DefaultSize)
|
||||
chunks[i] = c
|
||||
log.Trace("generate random chunk", "idx", i, "chunk", c)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/shed"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
|
@ -243,7 +242,7 @@ func init() {
|
|||
// random data, and their execution time can be decreased
|
||||
// using this function.
|
||||
func generateTestRandomChunk() chunk.Chunk {
|
||||
data := make([]byte, ch.DefaultSize)
|
||||
data := make([]byte, chunk.DefaultSize)
|
||||
rand.Read(data)
|
||||
key := make([]byte, 32)
|
||||
rand.Read(key)
|
||||
|
|
@ -261,16 +260,16 @@ func TestGenerateTestRandomChunk(t *testing.T) {
|
|||
t.Errorf("first chunk address length %v, want %v", addrLen, 32)
|
||||
}
|
||||
dataLen := len(c1.Data())
|
||||
if dataLen != ch.DefaultSize {
|
||||
t.Errorf("first chunk data length %v, want %v", dataLen, ch.DefaultSize)
|
||||
if dataLen != chunk.DefaultSize {
|
||||
t.Errorf("first chunk data length %v, want %v", dataLen, chunk.DefaultSize)
|
||||
}
|
||||
addrLen = len(c2.Address())
|
||||
if addrLen != 32 {
|
||||
t.Errorf("second chunk address length %v, want %v", addrLen, 32)
|
||||
}
|
||||
dataLen = len(c2.Data())
|
||||
if dataLen != ch.DefaultSize {
|
||||
t.Errorf("second chunk data length %v, want %v", dataLen, ch.DefaultSize)
|
||||
if dataLen != chunk.DefaultSize {
|
||||
t.Errorf("second chunk data length %v, want %v", dataLen, chunk.DefaultSize)
|
||||
}
|
||||
if bytes.Equal(c1.Address(), c2.Address()) {
|
||||
t.Error("fake chunks addresses do not differ")
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -65,7 +65,7 @@ func TestValidator(t *testing.T) {
|
|||
// add content address validator and check puts
|
||||
// bad should fail, good should pass
|
||||
store.Validators = append(store.Validators, NewContentAddressValidator(hashfunc))
|
||||
chunks = GenerateRandomChunks(ch.DefaultSize, 2)
|
||||
chunks = GenerateRandomChunks(chunk.DefaultSize, 2)
|
||||
goodChunk = chunks[0]
|
||||
badChunk = chunks[1]
|
||||
copy(badChunk.Data(), goodChunk.Data())
|
||||
|
|
@ -83,7 +83,7 @@ func TestValidator(t *testing.T) {
|
|||
var negV boolTestValidator
|
||||
store.Validators = append(store.Validators, negV)
|
||||
|
||||
chunks = GenerateRandomChunks(ch.DefaultSize, 2)
|
||||
chunks = GenerateRandomChunks(chunk.DefaultSize, 2)
|
||||
goodChunk = chunks[0]
|
||||
badChunk = chunks[1]
|
||||
copy(badChunk.Data(), goodChunk.Data())
|
||||
|
|
@ -101,7 +101,7 @@ func TestValidator(t *testing.T) {
|
|||
var posV boolTestValidator = true
|
||||
store.Validators = append(store.Validators, posV)
|
||||
|
||||
chunks = GenerateRandomChunks(ch.DefaultSize, 2)
|
||||
chunks = GenerateRandomChunks(chunk.DefaultSize, 2)
|
||||
goodChunk = chunks[0]
|
||||
badChunk = chunks[1]
|
||||
copy(badChunk.Data(), goodChunk.Data())
|
||||
|
|
@ -138,7 +138,7 @@ func putChunks(store *LocalStore, chunks ...Chunk) []error {
|
|||
|
||||
func put(store *LocalStore, n int, f func(i int64) Chunk) (hs []Address, errs []error) {
|
||||
for i := int64(0); i < int64(n); i++ {
|
||||
chunk := f(ch.DefaultSize)
|
||||
chunk := f(chunk.DefaultSize)
|
||||
err := store.Put(context.TODO(), chunk)
|
||||
errs = append(errs, err)
|
||||
hs = append(hs, chunk.Address())
|
||||
|
|
@ -158,7 +158,7 @@ func TestGetFrequentlyAccessedChunkWontGetGarbageCollected(t *testing.T) {
|
|||
|
||||
var chunks []Chunk
|
||||
for i := 0; i < ldbCap; i++ {
|
||||
chunks = append(chunks, GenerateRandomChunk(ch.DefaultSize))
|
||||
chunks = append(chunks, GenerateRandomChunk(chunk.DefaultSize))
|
||||
}
|
||||
|
||||
mostAccessed := chunks[0].Address()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
)
|
||||
|
||||
var sourcePeerID = enode.HexID("99d8594b52298567d2ca3f4c441a5ba0140ee9245e26460d01102a52773c73b9")
|
||||
|
|
@ -114,7 +114,7 @@ func mustNewNetStoreWithFetcher(t *testing.T) (*NetStore, *mockNetFetcher) {
|
|||
func TestNetStoreGetAndPut(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
|
|
@ -174,7 +174,7 @@ func TestNetStoreGetAndPut(t *testing.T) {
|
|||
func TestNetStoreGetAfterPut(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
|
|
@ -209,7 +209,7 @@ func TestNetStoreGetAfterPut(t *testing.T) {
|
|||
func TestNetStoreGetTimeout(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
|
|
@ -261,7 +261,7 @@ func TestNetStoreGetTimeout(t *testing.T) {
|
|||
func TestNetStoreGetCancel(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ func TestNetStoreGetCancel(t *testing.T) {
|
|||
func TestNetStoreMultipleGetAndPut(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
|
|
@ -387,7 +387,7 @@ func TestNetStoreMultipleGetAndPut(t *testing.T) {
|
|||
func TestNetStoreFetchFuncTimeout(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
defer cancel()
|
||||
|
|
@ -426,7 +426,7 @@ func TestNetStoreFetchFuncTimeout(t *testing.T) {
|
|||
func TestNetStoreFetchFuncAfterPut(t *testing.T) {
|
||||
netStore := mustNewNetStore(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
|
|
@ -453,7 +453,7 @@ func TestNetStoreFetchFuncAfterPut(t *testing.T) {
|
|||
func TestNetStoreGetCallsRequest(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx := context.WithValue(context.Background(), "hopcount", uint8(5))
|
||||
ctx, cancel := context.WithTimeout(ctx, 200*time.Millisecond)
|
||||
|
|
@ -481,7 +481,7 @@ func TestNetStoreGetCallsRequest(t *testing.T) {
|
|||
func TestNetStoreGetCallsOffer(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
// If a source peer is added to the context, NetStore will handle it as an offer
|
||||
ctx := context.WithValue(context.Background(), "source", sourcePeerID.String())
|
||||
|
|
@ -567,7 +567,7 @@ func TestNetStoreFetcherCountPeers(t *testing.T) {
|
|||
func TestNetStoreFetchFuncCalledMultipleTimes(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
|
|
@ -632,7 +632,7 @@ func TestNetStoreFetchFuncCalledMultipleTimes(t *testing.T) {
|
|||
func TestNetStoreFetcherLifeCycleWithTimeout(t *testing.T) {
|
||||
netStore, fetcher := mustNewNetStoreWithFetcher(t)
|
||||
|
||||
chunk := GenerateRandomChunk(ch.DefaultSize)
|
||||
chunk := GenerateRandomChunk(chunk.DefaultSize)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/log"
|
||||
)
|
||||
|
||||
|
|
@ -97,11 +97,11 @@ func NewPyramidSplitterParams(addr Address, reader io.Reader, putter Putter, get
|
|||
New chunks to store are store using the putter which the caller provides.
|
||||
*/
|
||||
func PyramidSplit(ctx context.Context, reader io.Reader, putter Putter, getter Getter) (Address, func(context.Context) error, error) {
|
||||
return NewPyramidSplitter(NewPyramidSplitterParams(nil, reader, putter, getter, ch.DefaultSize)).Split(ctx)
|
||||
return NewPyramidSplitter(NewPyramidSplitterParams(nil, reader, putter, getter, chunk.DefaultSize)).Split(ctx)
|
||||
}
|
||||
|
||||
func PyramidAppend(ctx context.Context, addr Address, reader io.Reader, putter Putter, getter Getter) (Address, func(context.Context) error, error) {
|
||||
return NewPyramidSplitter(NewPyramidSplitterParams(addr, reader, putter, getter, ch.DefaultSize)).Append(ctx)
|
||||
return NewPyramidSplitter(NewPyramidSplitterParams(addr, reader, putter, getter, chunk.DefaultSize)).Append(ctx)
|
||||
}
|
||||
|
||||
// Entry to create a tree node
|
||||
|
|
|
|||
|
|
@ -25,26 +25,26 @@ import (
|
|||
"io"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/bmt"
|
||||
ch "github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
// MaxPO is the same as chunk.MaxPO for backward compatibility.
|
||||
const MaxPO = ch.MaxPO
|
||||
const MaxPO = chunk.MaxPO
|
||||
|
||||
// AddressLength is the same as chunk.AddressLength for backward compatibility.
|
||||
const AddressLength = ch.AddressLength
|
||||
const AddressLength = chunk.AddressLength
|
||||
|
||||
type SwarmHasher func() SwarmHash
|
||||
|
||||
// Address is an alias for chunk.Address for backward compatibility.
|
||||
type Address = ch.Address
|
||||
type Address = chunk.Address
|
||||
|
||||
// Proximity is the same as chunk.Proximity for backward compatibility.
|
||||
var Proximity = ch.Proximity
|
||||
var Proximity = chunk.Proximity
|
||||
|
||||
// ZeroAddr is the same as chunk.ZeroAddr for backward compatibility.
|
||||
var ZeroAddr = ch.ZeroAddr
|
||||
var ZeroAddr = chunk.ZeroAddr
|
||||
|
||||
func MakeHashFunc(hash string) SwarmHasher {
|
||||
switch hash {
|
||||
|
|
@ -56,7 +56,7 @@ func MakeHashFunc(hash string) SwarmHasher {
|
|||
return func() SwarmHash {
|
||||
hasher := sha3.NewLegacyKeccak256
|
||||
hasherSize := hasher().Size()
|
||||
segmentCount := ch.DefaultSize / hasherSize
|
||||
segmentCount := chunk.DefaultSize / hasherSize
|
||||
pool := bmt.NewTreePool(hasher, segmentCount, bmt.PoolSize)
|
||||
return bmt.New(pool)
|
||||
}
|
||||
|
|
@ -83,10 +83,10 @@ func (c AddressCollection) Swap(i, j int) {
|
|||
}
|
||||
|
||||
// Chunk is an alias for chunk.Chunk for backward compatibility.
|
||||
type Chunk = ch.Chunk
|
||||
type Chunk = chunk.Chunk
|
||||
|
||||
// NewChunk is the same as chunk.NewChunk for backward compatibility.
|
||||
var NewChunk = ch.NewChunk
|
||||
var NewChunk = chunk.NewChunk
|
||||
|
||||
func GenerateRandomChunk(dataSize int64) Chunk {
|
||||
hasher := MakeHashFunc(DefaultHash)()
|
||||
|
|
@ -196,9 +196,9 @@ func NewContentAddressValidator(hasher SwarmHasher) *ContentAddressValidator {
|
|||
}
|
||||
|
||||
// Validate that the given key is a valid content address for the given data
|
||||
func (v *ContentAddressValidator) Validate(chunk Chunk) bool {
|
||||
data := chunk.Data()
|
||||
if l := len(data); l < 9 || l > ch.DefaultSize+8 {
|
||||
func (v *ContentAddressValidator) Validate(ch Chunk) bool {
|
||||
data := ch.Data()
|
||||
if l := len(data); l < 9 || l > chunk.DefaultSize+8 {
|
||||
// log.Error("invalid chunk size", "chunk", addr.Hex(), "size", l)
|
||||
return false
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ func (v *ContentAddressValidator) Validate(chunk Chunk) bool {
|
|||
hasher.Write(data[8:])
|
||||
hash := hasher.Sum(nil)
|
||||
|
||||
return bytes.Equal(hash, chunk.Address())
|
||||
return bytes.Equal(hash, ch.Address())
|
||||
}
|
||||
|
||||
type ChunkStore interface {
|
||||
|
|
|
|||
Loading…
Reference in a new issue