configurable powTarget and powTime

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Roman Volosovskyi 2018-03-13 09:05:58 +01:00 committed by Julien Eluard
parent 02d46c34de
commit 25a5655e74
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
8 changed files with 37 additions and 19 deletions

2
.env
View File

@ -11,3 +11,5 @@ QUEUE_MESSAGE_ENABLED=1
MANY_WHISPER_TOPICS_ENABLED=0
RN_BRIDGE_THRESHOLD_WARNINGS=0
COMPILE_VIEWS_ENABLED=0
POW_TARGET=0.001
POW_TIME=1

View File

@ -11,3 +11,5 @@ QUEUE_MESSAGE_ENABLED=1
MANY_WHISPER_TOPICS_ENABLED=0
RN_BRIDGE_THRESHOLD_WARNINGS=0
COMPILE_VIEWS_ENABLED=0
POW_TARGET=0.001
POW_TIME=1

View File

@ -11,3 +11,5 @@ QUEUE_MESSAGE_ENABLED=0
MANY_WHISPER_TOPICS_ENABLED=0
RN_BRIDGE_THRESHOLD_WARNINGS=0
COMPILE_VIEWS_ENABLED=0
POW_TARGET=0.2
POW_TIME=1

View File

@ -45,6 +45,8 @@ node ('macos1') {
sh 'echo JSC_ENABLED=' + JSC_ENABLED + '>>' + '.env'
sh 'echo OFFLINE_INBOX_ENABLED=' + OFFLINE_INBOX_ENABLED + '>>' + '.env'
sh 'echo MANY_WHISPER_TOPICS_ENABLED=' + MANY_WHISPER_TOPICS_ENABLED + '>>' + '.env'
sh 'echo POW_TARGET=' + POW_TARGET + '>>' + '.env'
sh 'echo POW_TIME=' + POW_TIME + '>>' + '.env'
sh 'echo "**********************************************************************"'
sh 'echo PARAMETERIZED BUILD - USING CUSTOM ENVIRONMENT'

View File

@ -23,7 +23,8 @@
[status-im.native-module.core :as status]
[clojure.string :as string]
[status-im.utils.web3-provider :as web3-provider]
[status-im.utils.ethereum.core :as utils]))
[status-im.utils.ethereum.core :as utils]
[status-im.utils.config :as config]))
;;;; COFX
@ -83,7 +84,9 @@
:keypair {:public public-key
:private private-key}}))
contacts)
:post-error-callback #(re-frame/dispatch [::post-error %])})))
:post-error-callback #(re-frame/dispatch [::post-error %])
:pow-target config/pow-target
:pow-time config/pow-time})))
(re-frame/reg-fx
::web3-get-syncing

View File

@ -224,7 +224,8 @@
(defn run-delivery-loop!
[web3 {:keys [delivery-loop-ms-interval default-ttl ttl-config
send-online-s-interval online-message post-error-callback]
send-online-s-interval online-message post-error-callback
pow-target pow-time]
:as options}]
{:pre [(valid? ::delivery-options options)]}
(debug :run-delivery-loop!)
@ -243,7 +244,10 @@
;; check each message asynchronously
(when (should-be-retransmitted? options data)
(try
(let [message' (check-ttl message type ttl-config default-ttl)
(let [message' (-> message
(check-ttl type ttl-config default-ttl)
(assoc :powTarget pow-target
:powTime pow-time))
callback (delivery-callback web3 post-error-callback data message')]
(t/post-message! web3 message' callback))
(catch :default err

View File

@ -5,16 +5,16 @@
[taoensso.timbre :refer-macros [debug]]))
(s/def :shh/payload string?)
(s/def :shh/powTarget number?)
(s/def :shh/powTime number?)
(s/def :shh/message
(s/keys
:req-un [:shh/payload :message/ttl :message/sig :message/topic]))
:req-un [:shh/payload :message/ttl :message/sig :message/topic
:shh/powTarget :shh/powTime]))
(defn post-message!
[web3 message callback]
{:pre [(valid? :shh/message message)]}
(debug :post-message message)
(let [shh (u/shh web3)
message' (assoc message
:powTarget 0.001
:powTime 1)]
(.post shh (clj->js message') callback)))
(let [shh (u/shh web3)]
(.post shh (clj->js message) callback)))

View File

@ -33,3 +33,6 @@
(def many-whisper-topics-enabled? (enabled? (get-config :MANY_WHISPER_TOPICS_ENABLED 0)))
(def rn-bridge-threshold-warnings-enabled? (enabled? (get-config :RN_BRIDGE_THRESHOLD_WARNINGS 0)))
(def compile-views-enabled? (enabled? (get-config :COMPILE_VIEWS_ENABLED 0)))
(def pow-target (js/parseFloat (get-config :POW_TARGET "0.001")))
(def pow-time (js/parseInt (get-config :POW_TIME "1")))