Squash bugs. Update READMEs & docker config

This commit is contained in:
Mononaut 2022-02-18 19:33:06 -06:00
parent 9a630adf3e
commit 245543ec9b
6 changed files with 23 additions and 10 deletions

View File

@ -121,14 +121,19 @@ class TxStream {
} }
async fetchBlock (id, calledOnLoad) { async fetchBlock (id, calledOnLoad) {
if (!id) return
if (id !== lastBlockSeen) { if (id !== lastBlockSeen) {
console.log('downloading block', id) try {
const response = await fetch(`${this.apiUri}/block/${id}`, { console.log('downloading block', id)
method: 'GET' const response = await fetch(`${this.apiUri}/api/block/${id}`, {
}) method: 'GET'
let blockData = await response.json() })
console.log('downloaded block', id) let blockData = await response.json()
window.dispatchEvent(new CustomEvent('bitcoin_block', { detail: { block: blockData, realtime: !calledOnLoad} })) console.log('downloaded block', id)
window.dispatchEvent(new CustomEvent('bitcoin_block', { detail: { block: blockData, realtime: !calledOnLoad} }))
} catch (err) {
console.log("failed to download block ", id)
}
} else { } else {
console.log('already seen block ', lastBlockSeen) console.log('already seen block ', lastBlockSeen)
} }

View File

@ -1,5 +1,5 @@
import { writable, derived } from 'svelte/store' import { writable, derived } from 'svelte/store'
import { spring } from 'svelte/motion'; import { tweened } from 'svelte/motion';
import { makePollStore } from './utils/pollStore.js' import { makePollStore } from './utils/pollStore.js'
import LocaleCurrency from 'locale-currency' import LocaleCurrency from 'locale-currency'
import { currencies } from './utils/fx.js' import { currencies } from './utils/fx.js'
@ -82,7 +82,7 @@ export const devEvents = writable({
export const txCount = createCounter() export const txCount = createCounter()
export const lastBlockId = writable(null) export const lastBlockId = writable(null)
export const mempoolCount = spring(0) export const mempoolCount = tweened(0)
export const mempoolScreenHeight = writable(0) export const mempoolScreenHeight = writable(0)
export const frameRate = writable(null) export const frameRate = writable(null)
export const avgFrameRate = writable(null) export const avgFrameRate = writable(null)

View File

@ -24,6 +24,7 @@ services:
BITCOIN_HOST: "172.17.0.1" BITCOIN_HOST: "172.17.0.1"
BITCOIN_ZMQ_RAWBLOCK_PORT: "29000" BITCOIN_ZMQ_RAWBLOCK_PORT: "29000"
BITCOIN_ZMQ_RAWTX_PORT: "29001" BITCOIN_ZMQ_RAWTX_PORT: "29001"
BITCOIN_ZMQ_SEQUENCE_PORT: "29002"
BITCOIN_RPC_PORT: "8332" BITCOIN_RPC_PORT: "8332"
BITCOIN_RPC_USER: "bitcoin" BITCOIN_RPC_USER: "bitcoin"
BITCOIN_RPC_PASS: "correcthorsebatterystaple" BITCOIN_RPC_PASS: "correcthorsebatterystaple"

View File

@ -27,6 +27,7 @@ The API server expects the following environment variables to be set:
| BITCOIN_HOST | Bitcoin node host address | | BITCOIN_HOST | Bitcoin node host address |
| BITCOIN_ZMQ_RAWBLOCK_PORT | Bitcoin node ZMQ port for block events (to match `zmqpubrawblock` in bitcoin.conf) | | BITCOIN_ZMQ_RAWBLOCK_PORT | Bitcoin node ZMQ port for block events (to match `zmqpubrawblock` in bitcoin.conf) |
| BITCOIN_ZMQ_RAWTX_PORT | Bitcoin node ZMQ port for transaction events (to match `zmqpubrawtx` in bitcoin.conf) | | BITCOIN_ZMQ_RAWTX_PORT | Bitcoin node ZMQ port for transaction events (to match `zmqpubrawtx` in bitcoin.conf) |
| BITCOIN_ZMQ_SEQUENCE_PORT | Bitcoin node ZMQ port for sequence events (to match `zmqpubsequence` in bitcoin.conf) |
| BITCOIN_RPC_PORT | Bitcoin node RPC port | | BITCOIN_RPC_PORT | Bitcoin node RPC port |
| either | | | either | |
| BITCOIN_RPC_USER | Bitcoin node RPC user | | BITCOIN_RPC_USER | Bitcoin node RPC user |

View File

@ -14,6 +14,12 @@ Environment=LANG=en_US.UTF-8
Environment=PORT=<port> Environment=PORT=<port>
Environment=BITCOIN_RPC_USER=<rpc user> Environment=BITCOIN_RPC_USER=<rpc user>
Environment=BITCOIN_RPC_PASS=<rpc password> Environment=BITCOIN_RPC_PASS=<rpc password>
Environment=BITCOIN_HOST=<rpc host>
Environment=BITCOIN_RPC_PORT=<rpc port>
Environment=BITCOIN_ZMQ_RAWBLOCK_PORT=<zmq rawblock port>
Environment=BITCOIN_ZMQ_RAWTX_PORT=<zmq rawtx port>
Environment=BITCOIN_ZMQ_SEQUENCE_PORT=<zmq sequence port>
WorkingDirectory=<installation root>/server WorkingDirectory=<installation root>/server

View File

@ -12,7 +12,7 @@ defmodule BitcoinStream.Router do
json_decoder: Jason json_decoder: Jason
plug :dispatch plug :dispatch
match "/block/:hash" do match "/api/block/:hash" do
case get_block(hash) do case get_block(hash) do
{:ok, block} -> {:ok, block} ->
put_resp_header(conn, "cache-control", "public, max-age=604800, immutable") put_resp_header(conn, "cache-control", "public, max-age=604800, immutable")