Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion client/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { Observable as O } from './rxjs'
import {setAdapt} from '@cycle/run/lib/adapt';

import { getMempoolDepth, getConfEstimate, calcSegwitFeeGains } from './lib/fees'
import { isBitcoinNetwork } from './lib/network'
import getPrivacyAnalysis from './lib/privacy-analysis'
import { nativeAssetId, blockTxsPerPage, blocksPerPage } from './const'
import { nativeAssetId, blockTxsPerPage, blocksPerPage, difficultyPeriod } from './const'
import {
dbg,
combine,
Expand Down Expand Up @@ -174,6 +175,11 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
.startWith([]).scan((S, mod) => mod(S))
.share()

, latestBlock$ = blocks$
.map(blocks => blocks && blocks[0])
.filter(Boolean)
.distinctUntilChanged((a, b) => a.height == b.height)

, newBlockEntries$ = trackNewEntries(
blocks$,
block => block.id,
Expand Down Expand Up @@ -241,6 +247,14 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
, dashboardState$ = O.combineLatest(blocks$, mempoolRecent$, (blks, txs) =>
({ dashblocks: blks.slice(0, 5), dashTxs: txs.slice(0, 5)}))

, dashboardEpochStartBlock$ = reply('dashboard-epoch-start-block', true)
.map(r => ({ ...r.body, requestedHeight: r.request.height }))
.startWith(null)

, dashboardPreviousDifficultyBlock$ = reply('dashboard-previous-difficulty-block', true)
.map(r => ({ ...r.body, requestedHeight: r.request.height }))
.startWith(null)

// Fee estimates
, feeEst$ = reply('fee-est').startWith(null)

Expand Down Expand Up @@ -299,6 +313,22 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
.combineLatest(isReady$, loading$, (view, isReady, loading) =>
!isReady ? 'loading' : view || (loading ? 'loading' : 'notFound'))

, dashboardLatestBlock$ = isBitcoinNetwork
? latestBlock$
.combineLatest(view$, (block, view) => view == 'dashBoard' ? block : null)
.filter(Boolean)
.distinctUntilChanged((a, b) => a.height == b.height)
: O.empty()

, dashboardEpochStartHeight$ = dashboardLatestBlock$
.map(block => block.height - (block.height % difficultyPeriod))
.distinctUntilChanged()

, dashboardPreviousDifficultyHeight$ = dashboardEpochStartHeight$
.map(height => height - difficultyPeriod)
.filter(height => height >= 0)
.distinctUntilChanged()

Comment thread
agoodminute marked this conversation as resolved.
Resolved
// Page title
, title$ = O.merge(page$.mapTo(null)
, goAPILanding$.withLatestFrom(t$, (_, t) => t`Explorer API`)
Expand All @@ -314,6 +344,7 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
// App state
, state$ = combine({ t$, error$, tipHeight$, spends$
, goBlocks$, blocks$, nextBlocks$, prevBlocks$, dashboardState$
, dashboardEpochStartBlock$, dashboardPreviousDifficultyBlock$
, newBlockEntries$, newTxEntries$
, goBlock$, block$, blockStatus$, blockTxs$, nextBlockTxs$, prevBlockTxs$, openBlock$
, mempool$, mempoolRecent$, feeEst$, bitcoinMarketChart$
Expand Down Expand Up @@ -367,6 +398,19 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
// fetch block by height
, goHeight$.map(n => ({ category: 'height', method: 'GET', path: `/block-height/${n}` }))

// fetch dashboard difficulty comparison blocks
, dashboardEpochStartHeight$
.map(height => ({ category: 'dashboard-epoch-start-height', method: 'GET', path: `/block-height/${height}`, height, bg: true }))

, reply('dashboard-epoch-start-height', true)
.map(r => ({ category: 'dashboard-epoch-start-block', method: 'GET', path: `/block/${r.text}`, height: r.request.height, bg: true }))

, dashboardPreviousDifficultyHeight$
.map(height => ({ category: 'dashboard-previous-difficulty-height', method: 'GET', path: `/block-height/${height}`, height, bg: true }))

, reply('dashboard-previous-difficulty-height', true)
.map(r => ({ category: 'dashboard-previous-difficulty-block', method: 'GET', path: `/block/${r.text}`, height: r.request.height, bg: true }))

// push tx
, pushtx$.map(rawtx => ({ category: 'pushtx', method: 'POST', path: `/tx`, send: rawtx, type: 'text/plain' }))

Expand Down
8 changes: 8 additions & 0 deletions client/src/components/icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/src/const.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const blockTxsPerPage = 25
export const addrTxsPerPage = 25
export const blocksPerPage = 10
export const difficultyPeriod = 2016
export const maxMempoolTxs = 50
export const satoshisPerBitcoin = 100000000
export const averageNativeSegwitTransactionSize = 140
Expand Down
5 changes: 5 additions & 0 deletions client/src/lib/network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const activeNetwork = process.env.MENU_ACTIVE || "";

export const isBitcoinNetwork = activeNetwork
.toLowerCase()
.startsWith("bitcoin");
Loading