Json info (#115)
* make info return a json with an spr * add an `exec` target to the makefile
This commit is contained in:
parent
28ebb16767
commit
cf4a0a393e
5
Makefile
5
Makefile
|
@ -86,6 +86,11 @@ testAll: | build deps
|
|||
echo -e $(BUILD_MSG) "build/testCodex" "build/testContracts" && \
|
||||
$(ENV_SCRIPT) nim testAll $(NIM_PARAMS) codex.nims
|
||||
|
||||
# Builds the codex binary
|
||||
exec: | build deps
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim codex codex.nims
|
||||
|
||||
# symlink
|
||||
codex.nims:
|
||||
ln -s codex.nimble $@
|
||||
|
|
|
@ -46,7 +46,7 @@ proc test(name: string, srcDir = "tests/", lang = "c") =
|
|||
exec "build/" & name
|
||||
|
||||
task codex, "build codex binary":
|
||||
buildBinary "codex"
|
||||
buildBinary "codex", params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE"
|
||||
|
||||
task testCodex, "Build & run Codex tests":
|
||||
test "testCodex"
|
||||
|
|
|
@ -25,6 +25,7 @@ import pkg/stew/byteutils
|
|||
import pkg/confutils
|
||||
|
||||
import pkg/libp2p/routing_record
|
||||
import pkg/libp2pdht/discv5/spr as spr
|
||||
|
||||
import ../node
|
||||
import ../blocktype
|
||||
|
@ -260,14 +261,14 @@ proc initRestApi*(node: CodexNodeRef, conf: CodexConf): RestRouter =
|
|||
## Print rudimentary node information
|
||||
##
|
||||
|
||||
var addrs: string
|
||||
for a in node.switch.peerInfo.addrs:
|
||||
addrs &= "- " & $a & "\n"
|
||||
let json = %*{
|
||||
"id": $node.switch.peerInfo.peerId,
|
||||
"addrs": node.switch.peerInfo.addrs.mapIt( $it ),
|
||||
"repo": $conf.dataDir,
|
||||
"spr": node.switch.peerInfo.signedPeerRecord.toURI
|
||||
}
|
||||
|
||||
return RestApiResponse.response(
|
||||
"Id: " & $node.switch.peerInfo.peerId &
|
||||
"\nAddrs: \n" & addrs &
|
||||
"\nRoot Dir: " & $conf.dataDir)
|
||||
return RestApiResponse.response($json)
|
||||
|
||||
router.api(
|
||||
MethodGet,
|
||||
|
|
Loading…
Reference in New Issue