mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-24 14:22:13 +00:00
Mark seed nodes are caused (and sourced) by self.
This commit is contained in:
parent
7b64ba3d06
commit
4422baaca5
@ -51,6 +51,7 @@ func OptPeerKadID(p peer.ID) *PeerKadID {
|
||||
}
|
||||
|
||||
func NewLookupEvent(
|
||||
node peer.ID,
|
||||
id uuid.UUID,
|
||||
key string,
|
||||
request *LookupUpdateEvent,
|
||||
@ -58,6 +59,7 @@ func NewLookupEvent(
|
||||
terminate *LookupTerminateEvent,
|
||||
) *LookupEvent {
|
||||
return &LookupEvent{
|
||||
Node: NewPeerKadID(node),
|
||||
ID: id,
|
||||
Key: NewKeyKadID(key),
|
||||
Request: request,
|
||||
@ -69,7 +71,9 @@ func NewLookupEvent(
|
||||
// LookupEvent is emitted for every notable event that happens during a DHT lookup.
|
||||
// LookupEvent supports JSON marshalling because all of its fields do, recursively.
|
||||
type LookupEvent struct {
|
||||
// ID is a unique identifier for the lookup instance
|
||||
// Node is the ID of the node performing the lookup.
|
||||
Node *PeerKadID
|
||||
// ID is a unique identifier for the lookup instance.
|
||||
ID uuid.UUID
|
||||
// Key is the Kademlia key used as a lookup target.
|
||||
Key *KeyKadID
|
||||
|
5
query.go
5
query.go
@ -237,7 +237,7 @@ func (q *query) run() {
|
||||
alpha := q.dht.alpha
|
||||
|
||||
ch := make(chan *queryUpdate, alpha)
|
||||
ch <- &queryUpdate{heard: q.seedPeers}
|
||||
ch <- &queryUpdate{cause: q.dht.self, heard: q.seedPeers}
|
||||
|
||||
for {
|
||||
var cause peer.ID
|
||||
@ -283,6 +283,7 @@ func (q *query) spawnQuery(ctx context.Context, cause peer.ID, ch chan<- *queryU
|
||||
} else {
|
||||
PublishLookupEvent(ctx,
|
||||
NewLookupEvent(
|
||||
q.dht.self,
|
||||
q.id,
|
||||
q.key,
|
||||
NewLookupUpdateEvent(
|
||||
@ -339,6 +340,7 @@ func (q *query) terminate(ctx context.Context, cancel context.CancelFunc, reason
|
||||
} else {
|
||||
PublishLookupEvent(ctx,
|
||||
NewLookupEvent(
|
||||
q.dht.self,
|
||||
q.id,
|
||||
q.key,
|
||||
nil,
|
||||
@ -388,6 +390,7 @@ func (q *query) queryPeer(ctx context.Context, ch chan<- *queryUpdate, p peer.ID
|
||||
func (q *query) updateState(ctx context.Context, up *queryUpdate) {
|
||||
PublishLookupEvent(ctx,
|
||||
NewLookupEvent(
|
||||
q.dht.self,
|
||||
q.id,
|
||||
q.key,
|
||||
nil,
|
||||
|
Loading…
x
Reference in New Issue
Block a user