diff options
| author | Ran Guin <[email protected]> | 2021-06-16 22:08:57 -0700 |
|---|---|---|
| committer | Ran Guin <[email protected]> | 2021-06-16 22:08:57 -0700 |
| commit | f66dec830f388817642f5f37c1572a6e3d58b084 (patch) | |
| tree | 16f8c079256f8a4507ceed26aef278feb8dc302d | |
| parent | 75149f56201dff56a2008266e69f23ae6e5f5e58 (diff) | |
| download | coinos-server-f66dec830f388817642f5f37c1572a6e3d58b084.tar.gz coinos-server-f66dec830f388817642f5f37c1572a6e3d58b084.zip | |
use static assets if they exist and blockstream fails
| -rw-r--r-- | routes/assets.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/routes/assets.js b/routes/assets.js index 734ea183..6e845ac8 100644 --- a/routes/assets.js +++ b/routes/assets.js @@ -4,17 +4,20 @@ const crypto = require("crypto"); let fetchAssets; (fetchAssets = async () => { try { - /* const { data: assets } = await axios.get( "https://assets.blockstream.info/" ); - */ - assets = require("../assets.json"); - app.set("assets", assets); } catch (e) { - l.error("error fetching assets", e.message); - res.status(500).send("error fetching assets"); + + assets = require('./../assets.json') + if (assets) { + app.set("assets", assets); + console.debug('using static assets...'); + } else { + l.error("error fetching assets", e.message); + res.status(500).send("error fetching assets"); + } } setTimeout(fetchAssets, 7200000); @@ -26,7 +29,7 @@ app.get( if (app.get("assets")) { const assets = app.get("assets"); const accounts = await db.Account.findAll({ - group: ["asset"] + // group: ["asset"] }); Object.keys(assets).map(a => { @@ -93,7 +96,7 @@ app.post( ticker, version }; - + l.info("attempting issuance", req.user.username, contract); sha256.update(JSON.stringify(contract)); |
