add waitinit

Signed-off-by: Chen Kai <281165273grape@gmail.com>
This commit is contained in:
Chen Kai 2024-12-10 14:33:42 +08:00
parent 5095282864
commit 0f8cc5fcd2
2 changed files with 10 additions and 0 deletions

View file

@ -695,6 +695,11 @@ func pushNode(list []*tableNode, n *tableNode, max int) ([]*tableNode, *tableNod
return list, removed
}
// waitInit waits until the table is initialized.
func (tab *Table) waitInit() {
<-tab.initDone
}
// nodeList returns all nodes contained in the table.
func (tab *Table) nodeList() []*enode.Node {
if !tab.isInitDone() {

View file

@ -281,6 +281,11 @@ func (t *UDPv5) DeleteNode(n *enode.Node) {
t.tab.deleteNode(n)
}
// WaitInit waits for the routing table to be initialized.
func (t *UDPv5) WaitInit() {
t.tab.waitInit()
}
// LocalNode returns the current local Node running the
// protocol.
func (t *UDPv5) LocalNode() *enode.LocalNode {