mirror of
https://github.com/Retropex/bitfeed.git
synced 2025-05-12 19:20:46 +02:00
Fix block layout bug
This commit is contained in:
parent
707abbc075
commit
34d991a998
@ -1,4 +1,12 @@
|
||||
import TxMondrianPoolScene from './TxMondrianPoolScene.js'
|
||||
import { settings } from '../stores.js'
|
||||
import { logTxSize, byteTxSize } from '../utils/misc.js'
|
||||
import config from '../config.js'
|
||||
|
||||
let settingsValue
|
||||
settings.subscribe(v => {
|
||||
settingsValue = v
|
||||
})
|
||||
|
||||
export default class TxBlockScene extends TxMondrianPoolScene {
|
||||
constructor ({ width, height, unit = 4, padding = 1, blockId, controller, heightStore, colorMode }) {
|
||||
@ -47,6 +55,12 @@ export default class TxBlockScene extends TxMondrianPoolScene {
|
||||
this.resetLayout()
|
||||
}
|
||||
|
||||
// calculates and returns the size of the tx in multiples of the grid size
|
||||
txSize (tx={ value: 1, vbytes: 1 }) {
|
||||
if (settingsValue.vbytes) return byteTxSize(tx.vbytes, Math.Infinity)
|
||||
else return logTxSize(tx.value, Math.Infinity)
|
||||
}
|
||||
|
||||
setTxOnScreen (tx, pixelPosition) {
|
||||
if (!tx.view.initialised) {
|
||||
tx.view.update({
|
||||
|
@ -498,7 +498,6 @@ defmodule BitcoinStream.Mempool do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
defp cache_spend(txid, index, input) do
|
||||
:ets.insert(:spend_cache, {[input.prev_txid, input.prev_vout], [txid, index]})
|
||||
end
|
||||
|
@ -65,7 +65,7 @@ defmodule BitcoinStream.Router do
|
||||
|> send_resp(200, spends)
|
||||
_ ->
|
||||
Logger.debug("Error getting tx spends");
|
||||
send_resp(conn, 404, "Transaction not found")
|
||||
send_resp(conn, 200, "[]")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
Process.send_after(self(), :sync, 2000);
|
||||
{:ok, [dbref, indexed, false]}
|
||||
else
|
||||
{:ok, nil}
|
||||
{:ok, [nil, indexed, false]}
|
||||
end
|
||||
end
|
||||
|
||||
@ -57,7 +57,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
|
||||
@impl true
|
||||
def handle_call({:get_tx_spends, txid}, _from, [dbref, indexed, done]) do
|
||||
case get_transaction_spends(dbref, txid) do
|
||||
case get_transaction_spends(dbref, txid, (indexed != nil)) do
|
||||
{:ok, spends} ->
|
||||
{:reply, {:ok, spends}, [dbref, indexed, done]}
|
||||
|
||||
@ -207,7 +207,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
defp index_block_inputs(dbref, batch, txns) do
|
||||
spends = index_txs(txns, %{});
|
||||
Enum.each(spends, fn {binid, outputs} ->
|
||||
case get_chain_spends(dbref, binid) do
|
||||
case get_chain_spends(dbref, binid, true) do
|
||||
false ->
|
||||
Logger.error("uninitialised tx in input index: #{Base.encode16(binid, [case: :lower])}")
|
||||
:ok
|
||||
@ -296,8 +296,8 @@ defmodule BitcoinStream.Index.Spend do
|
||||
end
|
||||
end
|
||||
|
||||
defp get_chain_spends(dbref, binary_txid) do
|
||||
case :rocksdb.get(dbref, binary_txid, []) do
|
||||
defp get_chain_spends(dbref, binary_txid, use_index) do
|
||||
case (if use_index do :rocksdb.get(dbref, binary_txid, []) else :not_found end) do
|
||||
{:ok, spends} ->
|
||||
spends
|
||||
|
||||
@ -337,9 +337,9 @@ defmodule BitcoinStream.Index.Spend do
|
||||
unpack_spends(bin, [])
|
||||
end
|
||||
|
||||
defp get_transaction_spends(dbref, txid) do
|
||||
defp get_transaction_spends(dbref, txid, use_index) do
|
||||
binary_txid = Base.decode16!(txid, [case: :lower]);
|
||||
chain_spends = get_chain_spends(dbref, binary_txid);
|
||||
chain_spends = get_chain_spends(dbref, binary_txid, use_index);
|
||||
spend_list = unpack_spends(chain_spends);
|
||||
spend_list = add_mempool_spends(txid, spend_list);
|
||||
{:ok, spend_list}
|
||||
@ -380,7 +380,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
defp drop_block_inputs(dbref, batch, txns) do
|
||||
spends = index_txs(txns, %{});
|
||||
Enum.each(spends, fn {binid, outputs} ->
|
||||
case get_chain_spends(dbref, binid) do
|
||||
case get_chain_spends(dbref, binid, true) do
|
||||
false ->
|
||||
Logger.error("uninitialised tx in input index: #{Base.encode16(binid, [case: :lower])}")
|
||||
:ok
|
||||
|
Loading…
Reference in New Issue
Block a user