[Fix #2810] Support markTrustedPeer in web3.js

Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
This commit is contained in:
Foo Pang 2018-01-15 21:14:22 +08:00 committed by Dmitry Novotochinov
parent fe697bfcc8
commit e35edf1e90
No known key found for this signature in database
GPG Key ID: 267674DCC86628D9
2 changed files with 8 additions and 12 deletions

View File

@ -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 %]))))

View File

@ -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
(response-handler error-fn (fn [result]
(swap! trusted-peers conj enode)
(success-fn result)))))))
(.markTrustedPeer (utils/shh web3)
enode
(response-handler error-fn (fn [result]
(swap! trusted-peers conj enode)
(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)