[Fix #2810] Support markTrustedPeer in web3.js
Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
This commit is contained in:
parent
fe697bfcc8
commit
e35edf1e90
|
@ -226,7 +226,8 @@
|
|||
(re-frame/reg-fx
|
||||
::mark-trusted-peer
|
||||
(fn [{:keys [wnode web3]}]
|
||||
(inbox/mark-trusted-peer wnode
|
||||
(inbox/mark-trusted-peer web3
|
||||
wnode
|
||||
#(re-frame/dispatch [::mark-trusted-peer-success web3 %])
|
||||
#(re-frame/dispatch [::mark-trusted-peer-error %]))))
|
||||
|
||||
|
|
|
@ -44,19 +44,14 @@
|
|||
(swap! peers conj enode)
|
||||
(success-fn result))))))
|
||||
|
||||
;; TODO(oskarth): Use web3 binding to do (.markTrustedPeer web3 enode cb)
|
||||
(defn mark-trusted-peer [enode success-fn error-fn]
|
||||
(defn mark-trusted-peer [web3 enode success-fn error-fn]
|
||||
(if (@trusted-peers enode)
|
||||
(success-fn true)
|
||||
(let [args {:jsonrpc "2.0"
|
||||
:id 1
|
||||
:method "shh_markTrustedPeer"
|
||||
:params [enode]}
|
||||
payload (.stringify js/JSON (clj->js args))]
|
||||
(status/call-web3 payload
|
||||
(.markTrustedPeer (utils/shh web3)
|
||||
enode
|
||||
(response-handler error-fn (fn [result]
|
||||
(swap! trusted-peers conj enode)
|
||||
(success-fn result)))))))
|
||||
(success-fn result))))))
|
||||
|
||||
(defn request-messages [web3 wnode topic sym-key-id success-fn error-fn]
|
||||
(log/info "offline inbox: sym-key-id" sym-key-id)
|
||||
|
|
Loading…
Reference in New Issue