Mount component for holding tokenreg data

This commit is contained in:
Teemu Patja 2017-08-20 12:19:34 +03:00
parent 9c71e37e2a
commit 6acc1bfb96
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C

View File

@ -0,0 +1,26 @@
(ns commiteth.eth.token-data
(:require [commiteth.eth.token-registry :as token-reg]
[commiteth.config :refer [env]]
[mount.core :as mount]
[clojure.tools.logging :as log]))
(def token-data-atom (atom {}))
(mount/defstate
token-data
:start
(do
(log/info "token-data started")
(let [token-data
(if (env :on-testnet true)
(env :testnet-token-data {})
(token-reg/load-parity-tokenreg-data))]
(reset! token-data-atom token-data)))
:stop
(log/info "token-data stopped"))
(defn as-map []
@token-data-atom)
(defn token-info [mnemonic]
(get @token-data-atom (keyword mnemonic)))