Fixes in ParallelTxTracker

This commit is contained in:
Vitaliy Vlasov 2018-05-16 12:11:54 +03:00
parent 66b9bd6bb3
commit 745b157039
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
1 changed files with 5 additions and 4 deletions

View File

@ -68,9 +68,10 @@
ITxTracker
(try-reserve-nonce [this]
(let [nonce (get-nonce)
monitored-nonces (set (keys current-txs))
monitored-nonces (set (keys @current-txs))
first-available-nonce (some #(if (monitored-nonces %1) nil %1) (iterate inc nonce))]
(swap! current-txs assoc nonce nil)))
(swap! current-txs assoc first-available-nonce nil)
first-available-nonce))
(drop-nonce [this nonce]
(swap! current-txs dissoc nonce))
@ -79,7 +80,7 @@
(swap! current-txs update (:nonce tx-info) merge tx-info))
(untrack-tx [this tx-info]
(when (contains? (set (keys current-txs)) (:nonce tx-info))
(when (contains? (set (keys @current-txs)) (:nonce tx-info))
(swap! current-txs dissoc (:nonce tx-info))))
(prune-txs [this unmined-txs]
@ -98,7 +99,7 @@
)
(def tx-tracker (SequentialTxTracker. (atom nil)))
(def tx-tracker (ParallelTxTracker. (atom nil)))
(defn try-reserve-nonce! []
(try-reserve-nonce tx-tracker))