diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-03-12 07:37:29 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-03-12 07:37:29 +0200 |
commit | 17659ce1983f39720de51b5fb898af515f701206 (patch) | |
tree | da3057beba1b7ac136f7b6d82323b70a88737128 | |
parent | 88e9bb162fecb6c44ac07b01e99fca1f69e2f5b6 (diff) | |
download | arching-kaos-tools-17659ce1983f39720de51b5fb898af515f701206.tar.gz arching-kaos-tools-17659ce1983f39720de51b5fb898af515f701206.tar.bz2 arching-kaos-tools-17659ce1983f39720de51b5fb898af515f701206.zip |
Caching enabled results and a fix
-rw-r--r-- | api/routes/getPeers/index.js | 2 | ||||
-rw-r--r-- | api/routes/getSLatest/index.js | 2 | ||||
-rw-r--r-- | api/routes/getZblock/index.js | 2 | ||||
-rwxr-xr-x | bin/ak-schain-latest-cached | 9 |
4 files changed, 12 insertions, 3 deletions
diff --git a/api/routes/getPeers/index.js b/api/routes/getPeers/index.js index 302f23a..699cebb 100644 --- a/api/routes/getPeers/index.js +++ b/api/routes/getPeers/index.js @@ -6,7 +6,7 @@ module.exports = (req, res) => { // const command = spawn("ak-config", ["get-published"]); const path = config.peersFile; if(fs.existsSync(path)){ - res.send(fs.readFileSync(path)); + res.send(JSON.parse(fs.readFileSync(path))); } else { res.send({"error":"404"}) } diff --git a/api/routes/getSLatest/index.js b/api/routes/getSLatest/index.js index 995fe69..5a31ae7 100644 --- a/api/routes/getSLatest/index.js +++ b/api/routes/getSLatest/index.js @@ -8,7 +8,7 @@ const HomeDir = os.userInfo().homedir; * sorry I was laughing at the term.. superchain */ module.exports = (req, res) => { - const command = spawn("ak-find-latest-mined-sblock"); + const command = spawn("ak-schain-latest-cached"); response_string = ""; command.stdout.on("data", data => { response_string = response_string + data; diff --git a/api/routes/getZblock/index.js b/api/routes/getZblock/index.js index c975594..a9ec02c 100644 --- a/api/routes/getZblock/index.js +++ b/api/routes/getZblock/index.js @@ -12,7 +12,7 @@ const config = require("../../config"); */ function fetchZblock(zblock, res){ regex= /Qm[A-Za-z0-9]{44}/; - if (regex.test(req.params.zblock)){ + if (regex.test(zblock)){ const command = spawn("ak-zblock-cache",[zblock]); command.stdout.on("data", data => { }); diff --git a/bin/ak-schain-latest-cached b/bin/ak-schain-latest-cached new file mode 100755 index 0000000..87d9194 --- /dev/null +++ b/bin/ak-schain-latest-cached @@ -0,0 +1,9 @@ +#!/bin/bash + +PROGRAM="$(basename $0)" +source $AK_LIBDIR/logit +if [ ! -f $AK_WORKDIR/schain.latest ] +then + ak-find-latest-mined-sblock > $AK_WORKDIR/schain.latest +fi +cat $AK_WORKDIR/schain.latest |