Repository navigation
feat(insight): serve the stock Firo Insight routes and labels - #34
Merged
Merged
Conversation
Blockbook's native Insight listener can now stand in for the stock Firo Insight (insight-api-zcoin 0.4.5). A chain parser that implements InsightExtension() gets that named extension; only the Firo parser does, so other coins keep the generic route table, currency shape and tx output. The Firo extension serves masternode/listmasternodes, masternode/listmasternodesarray[/:filter] (GET and POST, stock filter rules), masternode/masternodecount, currency in the stock shape, ext/getmoneysupply, the zerocoin/sigma supply, total and txid routes, and sparknames, each from the firod call stock makes, cached 30-60 s. Insight tx output gets stock's private spend/mint labels and, for Spark name registrations, sparkData and the synthetic "sparkname" output. configs/coins/firo.json gets fiat rates from the ZelCore rates service (CoinGecko id zcoin), as zcash.json does.
- listmasternodesarray: cap the filter at 4 KiB and 100 distinct items (400 above, for body, path and query forms), dedupe items, build each node's searchable JSON once per cached list, stop when the request context ends. - insightCached: single-flight load outside the mutex, shared result or error, stale-on-error, errors cached 5 s without a good value, waiters give up when their context ends. - Spark names: cache only daemon answers (not transport or warm-up errors); two-generation bound instead of wiping all entries. - Synthetic sparkname output writes scriptPubKey hex and asm as "", as stock; other outputs unchanged.
firod answers -25 both for a known tx that registers no Spark name and for a tx it cannot find yet; caching the second would hide a name for 10 minutes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets the FIRO Insight explorer move from the stock insight-api-zcoin 0.4.5 to Blockbook's native Insight listener without breaking its callers.
How it is scoped
A chain parser that implements
InsightExtension() string(server.InsightExtensionProvider) gets that named extension (server/insight_ext.go). OnlyFiroParserdoes. The extension only adds paths the generic router does not know, replacescurrency, and decorates converted txs. BTC/ZEC routes, currency shape and tx output are unchanged (covered byTestInsightFiroRoutesOnlyForFiro).Routes (
server/insight_firo.go)masternode/listmasternodesevoznodelistmasternode/listmasternodesarray[/:filter]GET + POSTevoznodelist, stock filter rulesmasternode/masternodecountevoznode countcurrency{zcoin_usd,btc_usd:0,btc_zcoin:0,bitstamp}ext/getmoneysupply,zerocoin/*andsigma/*totals/real supply/txidsgettotalsupply,getaddressbalance/getaddresstxidsof the pseudo-addressessparknamesgetsparknamesTx output: stock labels for private spends (
Zerospend,Sigmaspend,Lelantusjsplit,Sparkspend,Remintwith the tx output value) and mints (zerocoinmint/Zeromint…sparksmint/Sparksmint). For a Spark spend that registers a name it addssparkDataand the synthetic firstsparknameoutput and renumbers outputs, as stock does.getsparknametxdetailsis called only for Spark spends (stock calls it for every tx) and is cached.Differences from stock
idin the masternode envelopes is a listener counter, not firod's random JSON-RPC id.POST masternode/listmasternodesarray/:filteris 405 here (404 on stock).POST znodes/listznodesarrayis not aliased. Stock 0.4.5 answers 404 and so does this, so its callers see no change.richlist,sigmastatus,lelantusstatus(Postgres-backed, broken on stock).Fiat rates
configs/coins/firo.jsongets the zcash.json-style fiat config with CoinGecko idzcoin. Follow-up:viprates.zelcore.io/v2/blockbook/api/v3/simple/price?ids=zcoinanswerscoin not foundtoday. Untilzcoinis enabled there,zcoin_usdstays 0, the same as stock today, and the fiat downloader logs errors.Tests
Fixtures in
server/testdata/insight_firo.jsonwere recorded from FIRO-01 (stock API plus firod, read-only). The masternode array/list/filter cases, including the form and JSON POST, comma lists with duplicates and the[::]:0→"[]"ip quirk, all match stock byte-for-byte apart fromid. The supply and total values, txid lists and sparknames also match. As a one-off check, the full 7287-node mainnet list was byte-identical to stock.go test -tags unittest ./server/ ./bchain/coins/firo/ ./api/ ./build/tools/ .passes, and so does-raceon the Insight tests. gofmt is clean.