mirror of
https://github.com/status-im/open-bounty.git
synced 2025-01-19 14:01:52 +00:00
log eth-rpc results + different req-id approach
This commit is contained in:
parent
2df66222fc
commit
4705b6619a
@ -122,18 +122,24 @@
|
|||||||
|
|
||||||
nil)))))
|
nil)))))
|
||||||
|
|
||||||
|
(def req-id-tracker
|
||||||
|
;; HACK to ensure previous random-number approach doesn't lead to
|
||||||
|
;; unintended collisions
|
||||||
|
(atom 0))
|
||||||
|
|
||||||
(defn eth-rpc
|
(defn eth-rpc
|
||||||
[method params]
|
[method params]
|
||||||
(let [request-id (rand-int 4096)
|
(let [request-id (swap! req-id-tracker inc)
|
||||||
body (json/write-str {:jsonrpc "2.0"
|
body {:jsonrpc "2.0"
|
||||||
:method method
|
:method method
|
||||||
:params params
|
:params params
|
||||||
:id request-id})
|
:id request-id}
|
||||||
options {:headers {"content-type" "application/json"}
|
options {:headers {"content-type" "application/json"}
|
||||||
:body body}
|
:body (json/write-str body)}
|
||||||
response @(post (eth-rpc-url) options)
|
response @(post (eth-rpc-url) options)
|
||||||
result (safe-read-str (:body response))]
|
result (safe-read-str (:body response))]
|
||||||
(log/debug body "\n" result)
|
(log/infof "eth-rpc req(%s) body: %s\neth-rpc req(%s) result: %s"
|
||||||
|
request-id body request-id result)
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
;; Ignore any responses that have mismatching request ID
|
;; Ignore any responses that have mismatching request ID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user