From d238693571676b3214fcc623b4fcb0813f2abb0e Mon Sep 17 00:00:00 2001 From: jangko Date: Fri, 14 Oct 2022 20:06:40 +0700 Subject: [PATCH] refactor: replace shallowCopy with something else --- eth/p2p/discovery.nim | 3 ++- eth/p2p/discoveryv5/routing_table.nim | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/eth/p2p/discovery.nim b/eth/p2p/discovery.nim index acff0ef..f1139c1 100644 --- a/eth/p2p/discovery.nim +++ b/eth/p2p/discovery.nim @@ -132,7 +132,8 @@ proc sendNeighbours*(d: DiscoveryProtocol, node: Node, neighbours: seq[Node]) = const MAX_NEIGHBOURS_PER_PACKET = 12 # TODO: Implement a smarter way to compute it type Neighbour = tuple[ip: IpAddress, udpPort, tcpPort: Port, pk: PublicKey] var nodes = newSeqOfCap[Neighbour](MAX_NEIGHBOURS_PER_PACKET) - shallow(nodes) + when not defined(nimSeqsV2): + shallow(nodes) template flush() = block: diff --git a/eth/p2p/discoveryv5/routing_table.nim b/eth/p2p/discoveryv5/routing_table.nim index 00f2965..5ffb09c 100644 --- a/eth/p2p/discoveryv5/routing_table.nim +++ b/eth/p2p/discoveryv5/routing_table.nim @@ -482,10 +482,10 @@ proc len*(r: RoutingTable): int = proc moveRight[T](arr: var openArray[T], a, b: int) = ## In `arr` move elements in range [a, b] right by 1. var t: T - shallowCopy(t, arr[b + 1]) + t = system.move(arr[b + 1]) for i in countdown(b, a): - shallowCopy(arr[i + 1], arr[i]) - shallowCopy(arr[a], t) + arr[i + 1] = system.move(arr[i]) + arr[a] = system.move(t) proc setJustSeen*(r: RoutingTable, n: Node) = ## Move `n` to the head (most recently seen) of its bucket.