Enable partitioned topic
This commit is contained in:
parent
dc0d42ee6b
commit
7f76e2fbf0
1
.env
1
.env
|
@ -18,3 +18,4 @@ POW_TIME=1
|
|||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||
RPC_NETWORKS_ONLY=0
|
||||
STICKERS_ENABLED=1
|
||||
PARTITIONED_TOPIC=1
|
||||
|
|
1
.env.e2e
1
.env.e2e
|
@ -15,3 +15,4 @@ POW_TARGET=0.002
|
|||
POW_TIME=1
|
||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||
STICKERS_ENABLED=0
|
||||
PARTITIONED_TOPIC=1
|
||||
|
|
|
@ -18,3 +18,4 @@ POW_TIME=1
|
|||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||
RPC_NETWORKS_ONLY=0
|
||||
STICKERS_ENABLED=1
|
||||
PARTITIONED_TOPIC=1
|
||||
|
|
|
@ -16,3 +16,4 @@ POW_TIME=1
|
|||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||
RPC_NETWORKS_ONLY=0
|
||||
STICKERS_ENABLED=0
|
||||
PARTITIONED_TOPIC=1
|
||||
|
|
|
@ -15,3 +15,4 @@ POW_TARGET=0.002
|
|||
POW_TIME=1
|
||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||
STICKERS_ENABLED=0
|
||||
PARTITIONED_TOPIC=1
|
||||
|
|
|
@ -16,3 +16,4 @@ POW_TIME=1
|
|||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||
RPC_NETWORKS_ONLY=1
|
||||
STICKERS_ENABLED=0
|
||||
PARTITIONED_TOPIC=1
|
||||
|
|
|
@ -53,9 +53,10 @@
|
|||
(let [{:keys [web3]} (:db cofx)
|
||||
current-public-key (accounts.db/current-public-key cofx)]
|
||||
{:shh/send-direct-message
|
||||
[{:web3 web3
|
||||
:src current-public-key
|
||||
:dst public-key
|
||||
[{:web3 web3
|
||||
:src current-public-key
|
||||
:dst public-key
|
||||
:topics (get-in cofx [:db :mailserver/topics])
|
||||
:payload ""}]}))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
|
|
@ -134,14 +134,15 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:shh/send-group-message
|
||||
{:web3 web3
|
||||
:src current-public-key
|
||||
:dsts destinations
|
||||
:success-event [:transport/message-sent
|
||||
chat-id
|
||||
message-id
|
||||
:group-user-message]
|
||||
:payload payload}}))))
|
||||
{:web3 web3
|
||||
:src current-public-key
|
||||
:dsts destinations
|
||||
:available-topics (get-in cofx [:db :mailserver/topics])
|
||||
:success-event [:transport/message-sent
|
||||
chat-id
|
||||
message-id
|
||||
:group-user-message]
|
||||
:payload payload}}))))
|
||||
|
||||
(fx/defn handle-membership-update-received
|
||||
"Extract signatures in status-go and act if successful"
|
||||
|
|
|
@ -209,6 +209,7 @@
|
|||
[{:web3 web3
|
||||
:src current-public-key
|
||||
:dst current-public-key
|
||||
:topics (get-in cofx [:db :mailserver/topics])
|
||||
:payload payload}]}))
|
||||
|
||||
(fx/defn send-installation-message-fx [cofx payload]
|
||||
|
|
|
@ -65,11 +65,12 @@
|
|||
"Sends the payload using to dst"
|
||||
[{:keys [db] :as cofx} dst success-event payload]
|
||||
(let [{:keys [web3]} db]
|
||||
{:shh/send-direct-message [{:web3 web3
|
||||
:success-event success-event
|
||||
:src (accounts.db/current-public-key cofx)
|
||||
:dst dst
|
||||
:payload payload}]}))
|
||||
{:shh/send-direct-message [{:web3 web3
|
||||
:success-event success-event
|
||||
:src (accounts.db/current-public-key cofx)
|
||||
:dst dst
|
||||
:topics (:mailserver/topics db)
|
||||
:payload payload}]}))
|
||||
|
||||
(fx/defn send-with-pubkey
|
||||
"Sends the payload using asymetric key (account `:public-key` in db) and fixed discovery topic"
|
||||
|
@ -81,13 +82,18 @@
|
|||
chat-id
|
||||
success-event
|
||||
payload)
|
||||
{:shh/post [{:web3 web3
|
||||
:success-event success-event
|
||||
:message (merge {:sig (accounts.db/current-public-key cofx)
|
||||
:pubKey chat-id
|
||||
:payload payload
|
||||
:topic (transport.topic/public-key->discovery-topic-hash chat-id)}
|
||||
whisper-opts)}]}))))
|
||||
(let [partitioned-topic-hash (transport.topic/public-key->discovery-topic-hash chat-id)
|
||||
topics (db :mailserver/topics)
|
||||
topic-hash (if (contains? topics partitioned-topic-hash)
|
||||
partitioned-topic-hash
|
||||
transport.topic/discovery-topic-hash)]
|
||||
{:shh/post [{:web3 web3
|
||||
:success-event success-event
|
||||
:message (merge {:sig (accounts.db/current-public-key cofx)
|
||||
:pubKey chat-id
|
||||
:payload payload
|
||||
:topic topic-hash}
|
||||
whisper-opts)}]})))))
|
||||
|
||||
(defrecord Message [content content-type message-type clock-value timestamp]
|
||||
StatusMessage
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
partitioned-topic
|
||||
utils/get-topic))
|
||||
|
||||
(def discovery-topic constants/contact-discovery)
|
||||
(def discovery-topic-hash (utils/get-topic constants/contact-discovery))
|
||||
|
||||
(defn public-key->discovery-topic
|
||||
|
@ -45,10 +46,15 @@
|
|||
(partitioned-topic public-key)
|
||||
constants/contact-discovery))
|
||||
|
||||
(defn public-key->discovery-topic-hash [public-key]
|
||||
(defn public-key->discovery-topic-hash
|
||||
[public-key]
|
||||
(if config/partitioned-topic-enabled?
|
||||
(partitioned-topic-hash public-key)
|
||||
discovery-topic-hash))
|
||||
|
||||
(defn discovery-topics [public-key]
|
||||
[(partitioned-topic-hash public-key) discovery-topic-hash])
|
||||
|
||||
(defn contains-topic?
|
||||
[available-topics topic]
|
||||
(contains? available-topics (utils/get-topic topic)))
|
||||
|
|
|
@ -80,12 +80,16 @@
|
|||
(re-frame/reg-fx
|
||||
:shh/send-direct-message
|
||||
(fn [post-calls]
|
||||
(doseq [{:keys [web3 payload src dst success-event error-event]
|
||||
(doseq [{:keys [web3 payload src dst success-event error-event topics]
|
||||
:or {error-event :transport/send-status-message-error}} post-calls]
|
||||
(let [direct-message {:pubKey dst
|
||||
:sig src
|
||||
:chat (transport.topic/public-key->discovery-topic dst)
|
||||
:payload payload}]
|
||||
(let [part-topic-hash (transport.topic/public-key->discovery-topic-hash dst)
|
||||
topic (if (contains? topics part-topic-hash)
|
||||
(transport.topic/public-key->discovery-topic dst)
|
||||
transport.topic/discovery-topic)
|
||||
direct-message {:pubKey dst
|
||||
:sig src
|
||||
:chat topic
|
||||
:payload payload}]
|
||||
(send-direct-message! web3 direct-message success-event error-event 1)))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
@ -107,12 +111,15 @@
|
|||
(re-frame/reg-fx
|
||||
:shh/send-group-message
|
||||
(fn [params]
|
||||
(let [{:keys [web3 payload chat src dsts success-event error-event]
|
||||
(let [{:keys [web3 payload src dsts success-event error-event available-topics]
|
||||
:or {error-event :transport/send-status-message-error}} params]
|
||||
(doseq [{:keys [public-key chat]} dsts]
|
||||
(let [message
|
||||
(let [topic (if (transport.topic/contains-topic? available-topics chat)
|
||||
chat
|
||||
transport.topic/discovery-topic)
|
||||
message
|
||||
(clj->js {:pubKey public-key
|
||||
:chat chat
|
||||
:chat topic
|
||||
:sig src
|
||||
:payload (-> payload
|
||||
transit/serialize
|
||||
|
|
Loading…
Reference in New Issue