diff options
Diffstat (limited to 'swarm/storage')
-rw-r--r-- | swarm/storage/mru/testutil.go | 5 | ||||
-rw-r--r-- | swarm/storage/netstore.go | 14 | ||||
-rw-r--r-- | swarm/storage/netstore_test.go | 11 |
3 files changed, 14 insertions, 16 deletions
diff --git a/swarm/storage/mru/testutil.go b/swarm/storage/mru/testutil.go index a30baaa1d..936132d40 100644 --- a/swarm/storage/mru/testutil.go +++ b/swarm/storage/mru/testutil.go @@ -22,8 +22,7 @@ import ( "path/filepath" "sync" - "github.com/ethereum/go-ethereum/p2p/discover" - + "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/swarm/storage" ) @@ -43,7 +42,7 @@ type mockNetFetcher struct{} func (m *mockNetFetcher) Request(ctx context.Context) { } -func (m *mockNetFetcher) Offer(ctx context.Context, source *discover.NodeID) { +func (m *mockNetFetcher) Offer(ctx context.Context, source *enode.ID) { } func newFakeNetFetcher(context.Context, storage.Address, *sync.Map) storage.NetFetcher { diff --git a/swarm/storage/netstore.go b/swarm/storage/netstore.go index 80ac6f198..a3a552232 100644 --- a/swarm/storage/netstore.go +++ b/swarm/storage/netstore.go @@ -24,9 +24,8 @@ import ( "sync/atomic" "time" - "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/swarm/log" - lru "github.com/hashicorp/golang-lru" ) @@ -36,7 +35,7 @@ type ( type NetFetcher interface { Request(ctx context.Context) - Offer(ctx context.Context, source *discover.NodeID) + Offer(ctx context.Context, source *enode.ID) } // NetStore is an extension of local storage @@ -265,10 +264,11 @@ func (f *fetcher) Fetch(rctx context.Context) (Chunk, error) { // If there is a source in the context then it is an offer, otherwise a request sourceIF := rctx.Value("source") if sourceIF != nil { - var source *discover.NodeID - id := discover.MustHexID(sourceIF.(string)) - source = &id - f.netFetcher.Offer(rctx, source) + var source enode.ID + if err := source.UnmarshalText([]byte(sourceIF.(string))); err != nil { + return nil, err + } + f.netFetcher.Offer(rctx, &source) } else { f.netFetcher.Request(rctx) } diff --git a/swarm/storage/netstore_test.go b/swarm/storage/netstore_test.go index f08968f0e..b734c117b 100644 --- a/swarm/storage/netstore_test.go +++ b/swarm/storage/netstore_test.go @@ -25,17 +25,16 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/p2p/discover" - ch "github.com/ethereum/go-ethereum/swarm/chunk" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/p2p/enode" + ch "github.com/ethereum/go-ethereum/swarm/chunk" ) -var sourcePeerID = discover.MustHexID("2dd9d65c4552b5eb43d5ad55a2ee3f56c6cbc1c64a5c8d659f51fcd51bace24351232b8d7821617d2b29b54b81cdefb9b3e9c37d7fd5f63270bcc9e1a6f6a439") +var sourcePeerID = enode.HexID("99d8594b52298567d2ca3f4c441a5ba0140ee9245e26460d01102a52773c73b9") type mockNetFetcher struct { peers *sync.Map - sources []*discover.NodeID + sources []*enode.ID peersPerRequest [][]Address requestCalled bool offerCalled bool @@ -43,7 +42,7 @@ type mockNetFetcher struct { ctx context.Context } -func (m *mockNetFetcher) Offer(ctx context.Context, source *discover.NodeID) { +func (m *mockNetFetcher) Offer(ctx context.Context, source *enode.ID) { m.offerCalled = true m.sources = append(m.sources, source) } |