From 6acc1bfb96ab8fddb0cb926925acc7663dd496cd Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Sun, 20 Aug 2017 12:19:34 +0300 Subject: [PATCH] Mount component for holding tokenreg data --- src/clj/commiteth/eth/token_data.clj | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/clj/commiteth/eth/token_data.clj diff --git a/src/clj/commiteth/eth/token_data.clj b/src/clj/commiteth/eth/token_data.clj new file mode 100644 index 0000000..289c5c1 --- /dev/null +++ b/src/clj/commiteth/eth/token_data.clj @@ -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)))