Fix ImplicitDefaultValue warnings + replace some obsolete inits (#697)

This commit is contained in:
Kim De Mey 2024-06-10 21:19:25 +02:00 committed by GitHub
parent 50e71b2daa
commit 3d66c5b899
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 6 deletions

View File

@ -324,7 +324,8 @@ func update*(
r: var Record, r: var Record,
pk: PrivateKey, pk: PrivateKey,
ip: Option[IpAddress], ip: Option[IpAddress],
tcpPort, udpPort: Option[Port] = none[Port](), tcpPort: Option[Port] = none[Port](),
udpPort: Option[Port] = none[Port](),
extraFields: openArray[FieldPair] = []): extraFields: openArray[FieldPair] = []):
EnrResult[void] = EnrResult[void] =
## Update a `Record` with given ip address, tcp port, udp port and optional ## Update a `Record` with given ip address, tcp port, udp port and optional

View File

@ -59,7 +59,8 @@ func newNode*(r: Record): Result[Node, cstring] =
address: none(Address))) address: none(Address)))
func update*(n: Node, pk: PrivateKey, ip: Option[IpAddress], func update*(n: Node, pk: PrivateKey, ip: Option[IpAddress],
tcpPort, udpPort: Option[Port] = none[Port](), tcpPort: Option[Port] = none[Port](),
udpPort: Option[Port] = none[Port](),
extraFields: openArray[FieldPair] = []): Result[void, cstring] = extraFields: openArray[FieldPair] = []): Result[void, cstring] =
? n.record.update(pk, ip, tcpPort, udpPort, extraFields) ? n.record.update(pk, ip, tcpPort, udpPort, extraFields)

View File

@ -654,7 +654,7 @@ proc lookup*(d: Protocol, target: NodeId): Future[seq[Node]] {.async: (raises: [
var closestNodes = d.routingTable.neighbours(target, BUCKET_SIZE, var closestNodes = d.routingTable.neighbours(target, BUCKET_SIZE,
seenOnly = false) seenOnly = false)
var asked, seen = initHashSet[NodeId]() var asked, seen = HashSet[NodeId]()
asked.incl(d.localNode.id) # No need to ask our own node asked.incl(d.localNode.id) # No need to ask our own node
seen.incl(d.localNode.id) # No need to discover our own node seen.incl(d.localNode.id) # No need to discover our own node
for node in closestNodes: for node in closestNodes:
@ -717,7 +717,7 @@ proc query*(d: Protocol, target: NodeId, k = BUCKET_SIZE): Future[seq[Node]]
## the routing table, nodes returned by the first queries will be used. ## the routing table, nodes returned by the first queries will be used.
var queryBuffer = d.routingTable.neighbours(target, k, seenOnly = false) var queryBuffer = d.routingTable.neighbours(target, k, seenOnly = false)
var asked, seen = initHashSet[NodeId]() var asked, seen = HashSet[NodeId]()
asked.incl(d.localNode.id) # No need to ask our own node asked.incl(d.localNode.id) # No need to ask our own node
seen.incl(d.localNode.id) # No need to discover our own node seen.incl(d.localNode.id) # No need to discover our own node
for node in queryBuffer: for node in queryBuffer:

View File

@ -533,7 +533,7 @@ proc randomNodes*(r: RoutingTable, maxAmount: int,
maxAmount = sz maxAmount = sz
result = newSeqOfCap[Node](maxAmount) result = newSeqOfCap[Node](maxAmount)
var seen = initHashSet[Node]() var seen = HashSet[Node]()
# This is a rather inefficient way of randomizing nodes from all buckets, but even if we # This is a rather inefficient way of randomizing nodes from all buckets, but even if we
# iterate over all nodes in the routing table, the time it takes would still be # iterate over all nodes in the routing table, the time it takes would still be

View File

@ -121,7 +121,7 @@ proc new*[A](
rng = newRng()): UtpRouter[A] = rng = newRng()): UtpRouter[A] =
doAssert(not(isNil(acceptConnectionCb))) doAssert(not(isNil(acceptConnectionCb)))
UtpRouter[A]( UtpRouter[A](
sockets: initTable[UtpSocketKey[A], UtpSocket[A]](), sockets: Table[UtpSocketKey[A], UtpSocket[A]](),
acceptConnection: acceptConnectionCb, acceptConnection: acceptConnectionCb,
allowConnection: allowConnectionCb, allowConnection: allowConnectionCb,
socketConfig: socketConfig, socketConfig: socketConfig,