aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/fetcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'swarm/network/fetcher.go')
-rw-r--r--swarm/network/fetcher.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/swarm/network/fetcher.go b/swarm/network/fetcher.go
index 413b40cb5..5b4b61c7e 100644
--- a/swarm/network/fetcher.go
+++ b/swarm/network/fetcher.go
@@ -22,7 +22,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/swarm/storage"
)
@@ -32,7 +32,7 @@ var searchTimeout = 1 * time.Second
// Also used in stream delivery.
var RequestTimeout = 10 * time.Second
-type RequestFunc func(context.Context, *Request) (*discover.NodeID, chan struct{}, error)
+type RequestFunc func(context.Context, *Request) (*enode.ID, chan struct{}, error)
// Fetcher is created when a chunk is not found locally. It starts a request handler loop once and
// keeps it alive until all active requests are completed. This can happen:
@@ -41,18 +41,18 @@ type RequestFunc func(context.Context, *Request) (*discover.NodeID, chan struct{
// Fetcher self destroys itself after it is completed.
// TODO: cancel all forward requests after termination
type Fetcher struct {
- protoRequestFunc RequestFunc // request function fetcher calls to issue retrieve request for a chunk
- addr storage.Address // the address of the chunk to be fetched
- offerC chan *discover.NodeID // channel of sources (peer node id strings)
+ protoRequestFunc RequestFunc // request function fetcher calls to issue retrieve request for a chunk
+ addr storage.Address // the address of the chunk to be fetched
+ offerC chan *enode.ID // channel of sources (peer node id strings)
requestC chan struct{}
skipCheck bool
}
type Request struct {
- Addr storage.Address // chunk address
- Source *discover.NodeID // nodeID of peer to request from (can be nil)
- SkipCheck bool // whether to offer the chunk first or deliver directly
- peersToSkip *sync.Map // peers not to request chunk from (only makes sense if source is nil)
+ Addr storage.Address // chunk address
+ Source *enode.ID // nodeID of peer to request from (can be nil)
+ SkipCheck bool // whether to offer the chunk first or deliver directly
+ peersToSkip *sync.Map // peers not to request chunk from (only makes sense if source is nil)
}
// NewRequest returns a new instance of Request based on chunk address skip check and
@@ -112,14 +112,14 @@ func NewFetcher(addr storage.Address, rf RequestFunc, skipCheck bool) *Fetcher {
return &Fetcher{
addr: addr,
protoRequestFunc: rf,
- offerC: make(chan *discover.NodeID),
+ offerC: make(chan *enode.ID),
requestC: make(chan struct{}),
skipCheck: skipCheck,
}
}
// Offer is called when an upstream peer offers the chunk via syncing as part of `OfferedHashesMsg` and the node does not have the chunk locally.
-func (f *Fetcher) Offer(ctx context.Context, source *discover.NodeID) {
+func (f *Fetcher) Offer(ctx context.Context, source *enode.ID) {
// First we need to have this select to make sure that we return if context is done
select {
case <-ctx.Done():
@@ -156,13 +156,13 @@ func (f *Fetcher) Request(ctx context.Context) {
// it keeps the Fetcher alive within the lifecycle of the passed context
func (f *Fetcher) run(ctx context.Context, peers *sync.Map) {
var (
- doRequest bool // determines if retrieval is initiated in the current iteration
- wait *time.Timer // timer for search timeout
- waitC <-chan time.Time // timer channel
- sources []*discover.NodeID // known sources, ie. peers that offered the chunk
- requested bool // true if the chunk was actually requested
+ doRequest bool // determines if retrieval is initiated in the current iteration
+ wait *time.Timer // timer for search timeout
+ waitC <-chan time.Time // timer channel
+ sources []*enode.ID // known sources, ie. peers that offered the chunk
+ requested bool // true if the chunk was actually requested
)
- gone := make(chan *discover.NodeID) // channel to signal that a peer we requested from disconnected
+ gone := make(chan *enode.ID) // channel to signal that a peer we requested from disconnected
// loop that keeps the fetching process alive
// after every request a timer is set. If this goes off we request again from another peer
@@ -251,9 +251,9 @@ func (f *Fetcher) run(ctx context.Context, peers *sync.Map) {
// * the peer's address is added to the set of peers to skip
// * the peer's address is removed from prospective sources, and
// * a go routine is started that reports on the gone channel if the peer is disconnected (or terminated their streamer)
-func (f *Fetcher) doRequest(ctx context.Context, gone chan *discover.NodeID, peersToSkip *sync.Map, sources []*discover.NodeID) ([]*discover.NodeID, error) {
+func (f *Fetcher) doRequest(ctx context.Context, gone chan *enode.ID, peersToSkip *sync.Map, sources []*enode.ID) ([]*enode.ID, error) {
var i int
- var sourceID *discover.NodeID
+ var sourceID *enode.ID
var quit chan struct{}
req := &Request{
e49b796b72181a6ddd1c51900a25'>EditingKevin Breit2001-07-106-39/+52 * Validation.Aaron Weber2001-07-092-6/+8 * Mention UNMATCHEDKevin Breit2001-07-093-3/+24 * Spell checkKevin Breit2001-07-072-10/+12 * Spell checkKevin Breit2001-07-073-54/+58 * Added orderedlists.Kevin Breit2001-07-062-21/+84 * Added orderedlists.Kevin Breit2001-07-062-94/+132 * Added orderedlists.Kevin Breit2001-07-062-394/+484 * Chris pointed out an error in the DB versioning question.Aaron Weber2001-07-061-2/+1 * Put in lots of orderedlists...more SGML, less for the user to read.Kevin Breit2001-07-043-366/+650 * Updated slightly.Jeffrey Stedfast2001-07-033-85/+164 * Created its own file.Kevin Breit2001-07-037-406/+353 * Pulled organizing stuff, made its own file.Kevin Breit2001-07-018-1415/+1409 * Added evolution-alarm-notify.Federico Mena Quintero2001-07-011-1/+2 * Revised move/rename/copy questions, now that these functions work.Aaron Weber2001-06-272-35/+13 * Now that bug-buddy works with our bugzilla, update faq to reflect it.Aaron Weber2001-06-262-23/+26 * Put config-encryption in usage-mail.sgml. config-encryption.sgml should beKevin Breit2001-06-264-3/+153 * Elaborated on the mailing listsKevin Breit2001-06-262-0/+9 * Added info about mailing listsKevin Breit2001-06-262-115/+100 * Here too.Peter Williams2001-06-262-4/+6 * ... and comment out more exec summary stuff.Peter Williams2001-06-262-6/+10 * Fix make dist.Peter Williams2001-06-264-6/+13 * Fixed a few typosKevin Breit2001-06-252-2/+4 * Added section for importing filesKevin Breit2001-06-252-2/+63 * Removed some *'s that are causing problems.Kevin Breit2001-06-254-10/+12 * Sync - FedericoFederico Mena Quintero2001-06-259-169/+348 * Put in Contacts information in the quicktasks.Kevin Breit2001-06-232-18/+72 * Pulled some redundant information.Kevin Breit2001-06-222-9/+65 * Updated screenshots and redid layout for graphics on pages.battery8412001-06-226-28/+100 * disable executive summary build because it is no longer builtJP Rosevear2001-06-222-1/+6 * add new libJP Rosevear2001-06-222-1/+6 * Fixed .gif problemKevin Breit2001-06-224-12/+13 * Specify the file formatKevin Breit2001-06-222-2/+7 * Trying to fix the .gif problemKevin Breit2001-06-222-11/+20 * Redid graphics to add labels to them and described the labels in text.Kevin Breit2001-06-224-0/+40 * calendar/cal-client/Makefile.am: calendar/cal-util/Makefile.am:Peter Williams2001-06-226-428/+785 * Added config-encryption.sgml for buildingKevin Breit2001-06-223-0/+150 * Updated graphics for newer UI.Kevin Breit2001-06-2212-0/+4 * Redid graphics to add labels to them and described in labels in text.Kevin Breit2001-06-2210-20/+108 * Added fileKevin Breit2001-06-212-9/+160 * Moved my entires to doc/ChangeLog per request of danwKevin Breit2001-06-212-24/+57 * Updated for new UI.Kevin Breit2001-06-211-30/+18 * Updated for a newer UI (need to update at a later date.Kevin Breit2001-06-211-52/+34 * Make less monotone soundingKevin Breit2001-06-212-7/+5 * Added more postscript descriptionKevin Breit2001-06-211-3/+3 * Reworded a little bit for more descrip.Kevin Breit2001-06-211-2/+3 * Documented categorizing an event.Kevin Breit2001-06-211-2/+37 * Updated Bcc: exampleKevin Breit2001-06-201-1/+3 * Took out a reference to gloss.Kevin Breit2001-06-201-0/+10 * Made it build.Kevin Breit2001-06-201-1/+1 * Checked for validity.Aaron Weber2001-06-201-1/+7 * A couple changes to Kevin's update. Mostly just checking over.Aaron Weber2001-06-202-25/+26 * Basic editsKevin Breit2001-06-201-36/+42 * Updated to say "My Evolution"Kevin Breit2001-06-201-16/+12 * Added definition.Kevin Breit2001-06-201-73/+52 * Commented out DTD which shouldn't be thereKevin Breit2001-06-191-2/+2 * added *-undocumented.txt to .cvsignoreDamon Chaplin2001-06-142-0/+2 * added *-undocumented.txtDamon Chaplin2001-06-143-0/+7 * fixed a typo pointed out by Greg Leblanc. s/listen/listed/Duncan Mak2001-06-082-1/+5 * removed duplicate "If mozilla can..." question.Aaron Weber2001-06-071-17/+0