From b66a0fd88aef9388f161997e6bec0befb6da7ba0 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Tue, 23 Nov 2021 14:34:45 +0100 Subject: [PATCH] feat(general): node configuration added --- status/status.nim | 4 ++-- status/statusgo_backend_new/node_config.nim | 19 +++++++++++++++++++ test_nim/keycard.nim | 5 +++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 status/statusgo_backend_new/node_config.nim diff --git a/status/status.nim b/status/status.nim index f9d3985..4b97b1c 100644 --- a/status/status.nim +++ b/status/status.nim @@ -30,7 +30,7 @@ type Status* = ref object provider*: ProviderModel keycard*: KeycardModel -proc newStatusInstanceInternal(backendName: string = "statusgo"): Status = +proc newStatusInstance*(backendName: string): Status = result = Status() result.backend = newBackend(backendName) result.events = createEventEmitter() @@ -94,7 +94,7 @@ proc getBloomFilterBitsSet*(self: Status): int {.exportc, dynlib.} = proc newStatusInstance*(): Status {.exportc, dynlib.} = - newStatusInstanceInternal() + newStatusInstance("statusgo") proc initNode*(self: Status, statusGoDir, keystoreDir: cstring) {.exportc, dynlib.} = self.initNode($statusGoDir, $keystoreDir) diff --git a/status/statusgo_backend_new/node_config.nim b/status/statusgo_backend_new/node_config.nim new file mode 100644 index 0000000..8f0b67b --- /dev/null +++ b/status/statusgo_backend_new/node_config.nim @@ -0,0 +1,19 @@ +import json, json_serialization, chronicles +import ./core +import ./response_type + +import status_go + +export response_type + +logScope: + topics = "rpc-node-config" + +proc getNodeConfig*(): RpcResponse[JsonNode] {.raises: [Exception].} = + try: + let response = status_go.getNodeConfig() + result.result = response.parseJSON() + + except RpcException as e: + error "error doing rpc request", methodName = "getNodeConfig", exception=e.msg + raise newException(RpcException, e.msg) \ No newline at end of file diff --git a/test_nim/keycard.nim b/test_nim/keycard.nim index 7454c78..28be763 100644 --- a/test_nim/keycard.nim +++ b/test_nim/keycard.nim @@ -7,8 +7,9 @@ import ../status/keycard as keycard_module suite "#Keycard": setup: - let fleetConfig = "{\"fleets\":{\"eth.prod\":{\"boot\":{\"boot-01.ac-cn-hongkong-c.eth.prod\":\"enode://6e6554fb3034b211398fcd0f0082cbb6bd13619e1a7e76ba66e1809aaa0c5f1ac53c9ae79cf2fd4a7bacb10d12010899b370c75fed19b991d9c0cdd02891abad@47.75.99.169:443\"},\"mail\":{\"mail-01.ac-cn-hongkong-c.eth.prod\":\"enode://606ae04a71e5db868a722c77a21c8244ae38f1bd6e81687cc6cfe88a3063fa1c245692232f64f45bd5408fed5133eab8ed78049332b04f9c110eac7f71c1b429@47.75.247.214:443\"},\"rendezvous\":{\"boot-01.ac-cn-hongkong-c.eth.prod\":\"/ip4/47.75.99.169/tcp/30703/ethv4/16Uiu2HAmV8Hq9e3zm9TMVP4zrVHo3BjqW5D6bDVV6VQntQd687e4\"},\"whisper\":{\"node-01.ac-cn-hongkong-c.eth.prod\":\"enode://b957e51f41e4abab8382e1ea7229e88c6e18f34672694c6eae389eac22dab8655622bbd4a08192c321416b9becffaab11c8e2b7a5d0813b922aa128b82990dab@47.75.222.178:443\"}}},\"meta\":{\"hostname\":\"node-01.do-ams3.proxy.misc\",\"timestamp\":\"2021-09-09T00:00:14.760436\"}}"; - let statuslib_instance = newStatusInstance(fleetConfig, "mock") + # commented cause fleet configuration is moved to the status-desktop + #let fleetConfig = "{\"fleets\":{\"eth.prod\":{\"boot\":{\"boot-01.ac-cn-hongkong-c.eth.prod\":\"enode://6e6554fb3034b211398fcd0f0082cbb6bd13619e1a7e76ba66e1809aaa0c5f1ac53c9ae79cf2fd4a7bacb10d12010899b370c75fed19b991d9c0cdd02891abad@47.75.99.169:443\"},\"mail\":{\"mail-01.ac-cn-hongkong-c.eth.prod\":\"enode://606ae04a71e5db868a722c77a21c8244ae38f1bd6e81687cc6cfe88a3063fa1c245692232f64f45bd5408fed5133eab8ed78049332b04f9c110eac7f71c1b429@47.75.247.214:443\"},\"rendezvous\":{\"boot-01.ac-cn-hongkong-c.eth.prod\":\"/ip4/47.75.99.169/tcp/30703/ethv4/16Uiu2HAmV8Hq9e3zm9TMVP4zrVHo3BjqW5D6bDVV6VQntQd687e4\"},\"whisper\":{\"node-01.ac-cn-hongkong-c.eth.prod\":\"enode://b957e51f41e4abab8382e1ea7229e88c6e18f34672694c6eae389eac22dab8655622bbd4a08192c321416b9becffaab11c8e2b7a5d0813b922aa128b82990dab@47.75.222.178:443\"}}},\"meta\":{\"hostname\":\"node-01.do-ams3.proxy.misc\",\"timestamp\":\"2021-09-09T00:00:14.760436\"}}"; + let statuslib_instance = newStatusInstance("mock") test "start: should start listening to keycards": try: