Skip to content

Commit 4068bcb

Browse files
authored
fix: bump nph and refactor build process in makefile (#1410)
1 parent fef46ae commit 4068bcb

File tree

14 files changed

+90
-102
lines changed

14 files changed

+90
-102
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,11 @@ NPH:=$(shell dirname $(NIM_BINARY))/nph
214214

215215
build-nph:
216216
ifeq ("$(wildcard $(NPH))","")
217-
$(ENV_SCRIPT) nim c vendor/nph/src/nph.nim && \
218-
mv vendor/nph/src/nph $(shell dirname $(NPH))
219-
echo "nph utility is available at " $(NPH)
217+
cd vendor/nph && \
218+
nimble setup -l && \
219+
nimble build && \
220+
mv ./nph ../../$(shell dirname $(NPH)) && \
221+
echo "nph utility is available at " $(NPH)
220222
endif
221223

222224
GIT_PRE_COMMIT_HOOK := .git/hooks/pre-commit

build.nims

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ proc buildBinary(
2020

2121
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
2222
var extra_params = params
23-
when compiles(commandLineParams):
23+
when defined(commandLineParams):
2424
for param in commandLineParams():
2525
extra_params &= " " & param
2626
else:

codex/codex.nim

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,12 @@ proc stop*(s: CodexServer) {.async.} =
9696

9797
notice "Stopping Storage node"
9898

99-
var futures =
100-
@[
101-
s.codexNode.switch.stop(),
102-
s.codexNode.stop(),
103-
s.repoStore.stop(),
104-
s.maintenance.stop(),
105-
]
99+
var futures = @[
100+
s.codexNode.switch.stop(),
101+
s.codexNode.stop(),
102+
s.repoStore.stop(),
103+
s.maintenance.stop(),
104+
]
106105

107106
if s.restServer != nil:
108107
futures.add(s.restServer.stop())

codex/rest/api.nim

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,12 @@ proc initDataApi(node: CodexNodeRef, repoStore: RepoStore, router: var RestRoute
375375
return RestApiResponse.response($json, contentType = "application/json")
376376

377377
router.api(MethodGet, "/api/storage/v1/space") do() -> RestApiResponse:
378-
let json =
379-
%RestRepoStore(
380-
totalBlocks: repoStore.totalBlocks,
381-
quotaMaxBytes: repoStore.quotaMaxBytes,
382-
quotaUsedBytes: repoStore.quotaUsedBytes,
383-
quotaReservedBytes: repoStore.quotaReservedBytes,
384-
)
378+
let json = %RestRepoStore(
379+
totalBlocks: repoStore.totalBlocks,
380+
quotaMaxBytes: repoStore.quotaMaxBytes,
381+
quotaUsedBytes: repoStore.quotaUsedBytes,
382+
quotaReservedBytes: repoStore.quotaReservedBytes,
383+
)
385384
return RestApiResponse.response($json, contentType = "application/json")
386385

387386
proc initNodeApi(node: CodexNodeRef, conf: CodexConf, router: var RestRouter) =
@@ -477,20 +476,16 @@ proc initDebugApi(node: CodexNodeRef, conf: CodexConf, router: var RestRouter) =
477476
try:
478477
let table = RestRoutingTable.init(node.discovery.protocol.routingTable)
479478

480-
let json =
481-
%*{
482-
"id": $node.switch.peerInfo.peerId,
483-
"addrs": node.switch.peerInfo.addrs.mapIt($it),
484-
"repo": $conf.dataDir,
485-
"spr":
486-
if node.discovery.dhtRecord.isSome:
487-
node.discovery.dhtRecord.get.toURI
488-
else:
489-
"",
490-
"announceAddresses": node.discovery.announceAddrs,
491-
"table": table,
492-
"storage": {"version": $codexVersion, "revision": $codexRevision},
493-
}
479+
let json = %*{
480+
"id": $node.switch.peerInfo.peerId,
481+
"addrs": node.switch.peerInfo.addrs.mapIt($it),
482+
"repo": $conf.dataDir,
483+
"spr":
484+
if node.discovery.dhtRecord.isSome: node.discovery.dhtRecord.get.toURI else: "",
485+
"announceAddresses": node.discovery.announceAddrs,
486+
"table": table,
487+
"storage": {"version": $codexVersion, "revision": $codexRevision},
488+
}
494489

495490
# return pretty json for human readability
496491
return RestApiResponse.response(

config.nims

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ switch("define", "nimOldCaseObjects")
156156
# Enable compat mode for Chronos V4
157157
switch("define", "chronosHandleException")
158158

159-
# begin Nimble config (version 1)
160-
when system.fileExists("nimble.paths"):
159+
# begin Nimble config (version 2)
160+
when withDir(thisDir(), system.fileExists("nimble.paths")):
161161
include "nimble.paths"
162162
# end Nimble config

library/storage_thread_requests/requests/node_debug_request.nim

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ proc getDebug(
5252
let node = storage[].node
5353
let table = RestRoutingTable.init(node.discovery.protocol.routingTable)
5454

55-
let json =
56-
%*{
57-
"id": $node.switch.peerInfo.peerId,
58-
"addrs": node.switch.peerInfo.addrs.mapIt($it),
59-
"spr":
60-
if node.discovery.dhtRecord.isSome: node.discovery.dhtRecord.get.toURI else: "",
61-
"announceAddresses": node.discovery.announceAddrs,
62-
"table": table,
63-
}
55+
let json = %*{
56+
"id": $node.switch.peerInfo.peerId,
57+
"addrs": node.switch.peerInfo.addrs.mapIt($it),
58+
"spr":
59+
if node.discovery.dhtRecord.isSome: node.discovery.dhtRecord.get.toURI else: "",
60+
"announceAddresses": node.discovery.announceAddrs,
61+
"table": table,
62+
}
6463

6564
return ok($json)
6665

tests/codex/blockexchange/engine/testblockexc.nim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ asyncchecksuite "NetworkStore engine - 2 nodes":
5757

5858
check:
5959
(await allFinished(blocks1[0 .. 3].mapIt(nodeCmps2.localStore.getBlock(it.cid))))
60-
.filterIt(it.completed and it.read.isOk)
61-
.mapIt($it.read.get.cid)
62-
.sorted(cmp[string]) == blocks1[0 .. 3].mapIt($it.cid).sorted(cmp[string])
60+
.filterIt(it.completed and it.read.isOk)
61+
.mapIt($it.read.get.cid)
62+
.sorted(cmp[string]) == blocks1[0 .. 3].mapIt($it.cid).sorted(cmp[string])
6363

6464
(await allFinished(blocks2[0 .. 3].mapIt(nodeCmps1.localStore.getBlock(it.cid))))
65-
.filterIt(it.completed and it.read.isOk)
66-
.mapIt($it.read.get.cid)
67-
.sorted(cmp[string]) == blocks2[0 .. 3].mapIt($it.cid).sorted(cmp[string])
65+
.filterIt(it.completed and it.read.isOk)
66+
.mapIt($it.read.get.cid)
67+
.sorted(cmp[string]) == blocks2[0 .. 3].mapIt($it.cid).sorted(cmp[string])
6868

6969
test "Should send want-have for block":
7070
let blk = bt.Block.new("Block 1".toBytes).tryGet()
@@ -138,9 +138,9 @@ asyncchecksuite "NetworkStore - multiple nodes":
138138

139139
check:
140140
(await allFinished(downloadCids.mapIt(downloader.localStore.getBlock(it))))
141-
.filterIt(it.completed and it.read.isOk)
142-
.mapIt($it.read.get.cid)
143-
.sorted(cmp[string]) == downloadCids.mapIt($it).sorted(cmp[string])
141+
.filterIt(it.completed and it.read.isOk)
142+
.mapIt($it.read.get.cid)
143+
.sorted(cmp[string]) == downloadCids.mapIt($it).sorted(cmp[string])
144144

145145
test "Should exchange blocks with multiple nodes":
146146
let

tests/codex/node/helpers.nim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ template setupAndTearDown*() {.dirty.} =
9797

9898
blockDiscovery = Discovery.new(
9999
switch.peerInfo.privateKey,
100-
announceAddrs =
101-
@[
102-
MultiAddress.init("/ip4/127.0.0.1/tcp/0").expect("Should return multiaddress")
103-
],
100+
announceAddrs = @[
101+
MultiAddress.init("/ip4/127.0.0.1/tcp/0").expect("Should return multiaddress")
102+
],
104103
)
105104
peerStore = PeerCtxStore.new()
106105
pendingBlocks = PendingBlocksManager.new()

tests/codex/testlogutils.nim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,10 @@ checksuite "Test logging output":
205205
check loggedJson("ma", "\"/ip4/127.0.0.1/tcp/0\"")
206206

207207
test "logs seq[MultiAddress] correctly":
208-
let ma =
209-
@[
210-
MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet,
211-
MultiAddress.init("/ip4/127.0.0.2/tcp/1").tryGet,
212-
]
208+
let ma = @[
209+
MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet,
210+
MultiAddress.init("/ip4/127.0.0.2/tcp/1").tryGet,
211+
]
213212
log ma
214213
check logged("ma", "\"@[/ip4/127.0.0.1/tcp/0, /ip4/127.0.0.2/tcp/1]\"")
215214
check loggedJson("ma", "[\"/ip4/127.0.0.1/tcp/0\",\"/ip4/127.0.0.2/tcp/1\"]")

tests/codex/testnat.nim

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ suite "NAT Address Tests":
2222

2323
# Expected results
2424
let
25-
expectedDiscoveryAddrs =
26-
@[
27-
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
28-
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
29-
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
30-
]
31-
expectedlibp2pAddrs =
32-
@[
33-
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
34-
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
35-
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
36-
]
25+
expectedDiscoveryAddrs = @[
26+
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
27+
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
28+
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
29+
]
30+
expectedlibp2pAddrs = @[
31+
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
32+
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
33+
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
34+
]
3735

3836
#ipv6Addr = MultiAddress.init("/ip6/::1/tcp/5000").expect("valid multiaddr")
3937
addrs = @[localAddr, anyAddr, publicAddr]

0 commit comments

Comments
 (0)