diff --git a/miner/utils.ts b/miner/utils.ts index 1cd62a1..f6a8f91 100644 --- a/miner/utils.ts +++ b/miner/utils.ts @@ -37,7 +37,7 @@ export function printExecutionDetails(tx: TxSigned, name: string) { const remainingMem = MAX_TX_EX_MEM - mem; const remainingSteps = MAX_TX_EX_STEPS - steps; - const txBytes = tx.txSigned.to_cbor_bytes().length; + const txBytes = tx.txSigned.to_bytes().length; const remainingTxBytes = MAX_TX_SIZE - txBytes; const fee = tx.txSigned.body().fee().toString(); diff --git a/src/routes/explorer/+page.svelte b/src/routes/explorer/+page.svelte index d0c1c9d..6a7f863 100644 --- a/src/routes/explorer/+page.svelte +++ b/src/routes/explorer/+page.svelte @@ -3,6 +3,8 @@ import { goto } from '$app/navigation'; import type { PageData } from './$types'; + import { intlFormat } from 'date-fns/intlFormat'; + import { formatDistance } from 'date-fns/formatDistance'; export let data: PageData; @@ -15,14 +17,23 @@ newPage += delta; - console.log(newPage); - const query = new URLSearchParams($page.url.searchParams.toString()); query.set('page', newPage.toString()); goto(`?${query.toString()}`); } + + function formatHash(value: string) { + const regex = /^0{4,}|0{4,}$/g; + return value.replace(regex, (match) => `0${match.length} `); + } + + function makeTarget(target_number: number, leading_zeros: number) { + const value = target_number * 16 ** (60 - leading_zeros); + + return value.toString(16).padStart(64, '0'); + }
@@ -33,32 +44,30 @@
-
Epoch
Block
-
Leading Zeroes
Target
Hash
-
Rewards
+
Epoch
Time
{#each data.blocks as block (block.block_number)}
-
{block.epoch_time}
{block.block_number}
-
{block.leading_zeros}
- {block.target_number} + {@html formatHash(makeTarget(block.target_number, block.leading_zeros))} +
+
+ {@html formatHash(block.current_hash)}
- {block.current_hash} +
{Math.floor(block.block_number / 2016 + 1)}
-
{50}
+ {intlFormat(block.current_posix_time)}
-
{block.current_posix_time}
{/each}