Skip to content

Commit

Permalink
Remove find node function from Bootstrap method
Browse files Browse the repository at this point in the history
  • Loading branch information
iand committed Aug 16, 2023
1 parent 6ec9113 commit d7c3391
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions coord/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func (q *eventQueue[E]) Dequeue(ctx context.Context) (E, bool) {
}
}

// FindNodeRequestFunc is a function that creates a request to find the supplied node id
// TODO: consider this being a first class method of the Endpoint
type FindNodeRequestFunc[K kad.Key[K], A kad.Address[A]] func(kad.NodeID[K]) (address.ProtocolID, kad.Request[K, A])

// A Coordinator coordinates the state machines that comprise a Kademlia DHT
// Currently this is only queries and bootstrapping but will expand to include other state machines such as
// routing table refresh, and reproviding.
Expand Down Expand Up @@ -559,14 +563,10 @@ func (c *Coordinator[K, A]) AddNodes(ctx context.Context, infos []kad.NodeInfo[K
return nil
}

// FindNodeRequestFunc is a function that creates a request to find the supplied node id
// TODO: consider this being a first class method of the Endpoint
type FindNodeRequestFunc[K kad.Key[K], A kad.Address[A]] func(kad.NodeID[K]) (address.ProtocolID, kad.Request[K, A])

// Bootstrap instructs the coordinator to begin bootstrapping the routing table.
// While bootstrap is in progress, no other queries will make progress.
func (c *Coordinator[K, A]) Bootstrap(ctx context.Context, seeds []kad.NodeID[K], fn FindNodeRequestFunc[K, A]) error {
protoID, msg := fn(c.self)
func (c *Coordinator[K, A]) Bootstrap(ctx context.Context, seeds []kad.NodeID[K]) error {
protoID, msg := c.findNodeFn(c.self)

bev := &routing.EventBootstrapStart[K, A]{
ProtocolID: protoID,
Expand Down
2 changes: 1 addition & 1 deletion coord/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func TestBootstrap(t *testing.T) {
seeds := []kad.NodeID[key.Key8]{
nodes[1].ID(),
}
err = c.Bootstrap(ctx, seeds, findNodeFn)
err = c.Bootstrap(ctx, seeds)
require.NoError(t, err)

// the query run by the coordinator should have received a response from nodes[1]
Expand Down

0 comments on commit d7c3391

Please sign in to comment.