Documentation ¶
Index ¶
- Constants
- Variables
- type Controller
- func (c *Controller) GetClosestPeersFromStore(target []byte, n int) ([]address.PeerAddressInfo, error)
- func (c *Controller) OnPeerAccessed(id address.PeerId) error
- func (c *Controller) RunLookup(ctx context.Context, target []byte, k int, fn queryFn) ([]address.PeerAddressInfo, error)
- func (c *Controller) SearchWorker()
- func (c *Controller) SetBootNodes(bootNodes []string)
- func (c *Controller) Shutdown()
- func (c *Controller) StartPeerSearch()
- type LookupEvent
- type LookupTask
- type RequestProposal
Constants ¶
const (
DefaultBetaFactor int = 5
)
Variables ¶
var (
ErrNotBootstrapped = errors.New("peer routing controller is not bootstrapped")
)
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct { RoutingTable *routingtable.RoutingTable // The backing peer store Alpha int // The concurrency Parameter of the kademlia System. BootNodes []string // The boot nodes for initializing kademlia System. IsBootstrapped bool // Is the controller bootstrapped SelfAddr string // my addr in serialized addr format ControllerContext context.Context // The context for cancelling stuff ControllerCancelFunc context.CancelFunc // the cancel func for the controller. // contains filtered or unexported fields }
Controller - Handles all PeerRouting Related functionalities.
func NewRoutingController ¶
func NewRoutingController(rt *routingtable.RoutingTable, alpha int, bootNodes []string, sAddr string, fn func(string, []byte) ([]string, error)) *Controller
NewRoutingController initializes the controller
func (*Controller) GetClosestPeersFromStore ¶
func (c *Controller) GetClosestPeersFromStore(target []byte, n int) ([]address.PeerAddressInfo, error)
GetClosestPeersFromStore Returns the peers closest to target from the peer store. Not Expensive in terms of runtime. No network calls are made. Usually nodes from peer store forms the seed nodes for further queries like RunLookup. The size of result set is limited to n.
func (*Controller) OnPeerAccessed ¶
func (c *Controller) OnPeerAccessed(id address.PeerId) error
OnPeerAccessed When peer is accessed, delegate it to the Routing Table to handle it.
func (*Controller) RunLookup ¶
func (c *Controller) RunLookup(ctx context.Context, target []byte, k int, fn queryFn) ([]address.PeerAddressInfo, error)
RunLookup - Probably the most import API of peer routing. Employs a LookupTask to search for peers.
func (*Controller) SearchWorker ¶
func (c *Controller) SearchWorker()
func (*Controller) SetBootNodes ¶
func (c *Controller) SetBootNodes(bootNodes []string)
func (*Controller) Shutdown ¶
func (c *Controller) Shutdown()
func (*Controller) StartPeerSearch ¶
func (c *Controller) StartPeerSearch()
type LookupEvent ¶
LookupEvent are those events posted in main event channel
type LookupTask ¶
type LookupTask struct {
// contains filtered or unexported fields
}
LookupTask is a recursive task that performs the "kademlia lookup" for a given target. It ends when either of the following conditions are met 1. There are no more peers to query from. Happy Case - Converged. 2. queries are exhausted 3. deadlineContext is done In all the cases it returns the peers it has found so far, I mean it doesn't actually return Peer controller should/wound return whatever peers in table.
func NewLookupTask ¶
func NewLookupTask(target []byte, availableQuerySlot int, ctx context.Context, me string, alpha int, nodeTable *routingtable.RoutingTable, query queryFn) *LookupTask
NewLookupTask creates and returns a new Lookup task ready to run
func (*LookupTask) GetActive ¶ added in v0.0.4
func (lt *LookupTask) GetActive(list []routingtable.PeerBucketInfo) []routingtable.PeerBucketInfo
func (*LookupTask) GetDone ¶
func (lt *LookupTask) GetDone() chan int
GetDone Returns the task completion chan
type RequestProposal ¶
type RequestProposal struct {
// contains filtered or unexported fields
}
RequestProposal is the request proposal for the dispatcher