Published
Edited
Aug 29, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
arrowDeals.schema.select('provider')
Insert cell
Insert cell
Insert cell
await client.version()
Insert cell
chainHead = await client.chainHead()
Insert cell
Insert cell
Insert cell
selectedHeight
Insert cell
tipSet = (await client.chainGetTipSetByHeight(selectedHeight, headTipSet)).Cids
Insert cell
Insert cell
deals = client.StateMarketDeals(tipSet)
Insert cell
Object.keys(deals).length
Insert cell
Insert cell
dealArray = [...Object.entries(deals)].map(([dealNumber, { Proposal, State }]) => ({ dealNumber, ...Proposal, ...State }))
Insert cell
arrowDeals = arrow.Table.new(
[
arrow.Uint32Vector.from(dealArray.map(deal => Number(deal.dealNumber))),
arrow.Vector.from({
values: dealArray.map(deal => deal.Client),
type: new arrow.Dictionary(new arrow.Utf8(), new arrow.Int32())
}),
arrow.Vector.from({
values: dealArray.map(deal => deal.Provider),
type: new arrow.Dictionary(new arrow.Utf8(), new arrow.Int32())
}),
arrow.Uint32Vector.from(dealArray.map(deal => Number(deal.PieceSize))),
arrow.Int32Vector.from(dealArray.map(deal => Number(deal.StartEpoch))),
arrow.Int32Vector.from(dealArray.map(deal => Number(deal.EndEpoch))),
arrow.Int32Vector.from(dealArray.map(deal => Number(deal.SectorStartEpoch))),
arrow.Int32Vector.from(dealArray.map(deal => Number(deal.SlashEpoch))),
arrow.BoolVector.from(dealArray.map(deal => deal.VerifiedDeal)),
arrow.Float64Vector.from(dealArray.map(deal => Number(deal.StoragePricePerEpoch)))
],
[
"dealNumber",
"client",
"provider",
"pieceSize",
"startEpoch",
"endEpoch",
"sectorStartEpoch",
"slashEpoch",
"verifiedDeal",
"storagePricePerEpoch"
]
)
Insert cell
arrowDeals.count()
Insert cell
viewof rowNumber = html`<input type=range max=${arrowDeals.count() - 1} value=${arrowDeals.count() - 1}>`
Insert cell
rowNumber
Insert cell
JSON.parse(`${arrowDeals.get(rowNumber)}`)
Insert cell
activeArrowDeals = arrowDeals.filter(arrow.predicate.col('sectorStartEpoch').ne(-1))
Insert cell
activeArrowDeals.count()
Insert cell
focusedArrowDeals = arrowDeals.filter(arrow.predicate.col('provider').eq(miner))
Insert cell
focusedArrowDeals.count()
Insert cell
focusedArrowDeals.toArray().map(m => Object.fromEntries(m))
Insert cell
activeArrowDeals.get(0)
Insert cell
arrowDeals.getColumn('dealNumber')
Insert cell
filteredFocusedDeals = {
const result = []
let sumPieceSize = 0
let dealNumber, client, provider, pieceSize, startEpoch, endEpoch, sectorStartEpoch, slashEpoch, verifiedDeal, storagePricePerEpoch
focusedArrowDeals.scan(idx => {
result.push({
dealNumber: Uint32Array.from([dealNumber(idx)])[0],
client: `${client(idx)}`,
provider: `${provider(idx)}`,
pieceSize: Uint32Array.from([pieceSize(idx)])[0],
startEpoch: Int32Array.from([startEpoch(idx)])[0],
endEpoch: Int32Array.from([endEpoch(idx)])[0],
sectorStartEpoch: Int32Array.from([sectorStartEpoch(idx)])[0],
slashEpoch: Int32Array.from([slashEpoch(idx)])[0],
verifiedDeal: verifiedDeal(idx),
storagePricePerEpoch: Float64Array.from([storagePricePerEpoch(idx)])[0]
})
let sectorStart = Int32Array.from([sectorStartEpoch(idx)])[0]
if (sectorStart >= 0) {
sumPieceSize += Uint32Array.from([pieceSize(idx)])[0]
}
}, batch => {
dealNumber = arrow.predicate.col('dealNumber').bind(batch)
client = arrow.predicate.col('client').bind(batch)
provider = arrow.predicate.col('provider').bind(batch)
pieceSize = arrow.predicate.col('pieceSize').bind(batch)
startEpoch = arrow.predicate.col('startEpoch').bind(batch)
endEpoch = arrow.predicate.col('endEpoch').bind(batch)
sectorStartEpoch = arrow.predicate.col('sectorStartEpoch').bind(batch)
slashEpoch = arrow.predicate.col('slashEpoch').bind(batch)
verifiedDeal = arrow.predicate.col('verifiedDeal').bind(batch)
storagePricePerEpoch = arrow.predicate.col('storagePricePerEpoch').bind(batch)
})
return { result, sumPieceSize }
}
Insert cell
Insert cell
LotusRPC = (await import('@filecoin-shipyard/lotus-client-rpc')).LotusRPC
Insert cell
BrowserProvider = (await import('@filecoin-shipyard/lotus-client-provider-browser')).BrowserProvider
Insert cell
schema = (await import('@filecoin-shipyard/lotus-client-schema')).testnet.fullNode
Insert cell
Insert cell
Object.keys(schema.methods)
Insert cell
Insert cell
endpointUrl = "wss://lotus.jimpick.com/spacerace_api/1/node/rpc/v0"
Insert cell
client = {
const provider = new BrowserProvider(endpointUrl)
return new LotusRPC(provider, { schema })
}
Insert cell
Insert cell
arrow = require('@apache-arrow/es5-umd@0.15.1')
Insert cell
Insert cell
Insert cell
function autoSelect(config = {}) {
// Based on @jashkenas/inputs autoSelect
const {
value,
title,
description,
disabled,
autocomplete = "off",
placeholder,
size,
options,
list = "options"
} = Array.isArray(config) ? { options: config } : config;

const optionsSet = new Set(options);

const form = input({
type: "text",
title,
description,
attributes: { disabled },
action: fm => {
fm.value = fm.input.value = value || "";
fm.onsubmit = e => e.preventDefault();
fm.input.oninput = function(e) {
e.stopPropagation();
fm.value = fm.input.value;
if (!fm.value || optionsSet.has(fm.value))
fm.dispatchEvent(new CustomEvent("input"));
};
},
form: html`
<form>
<input name="input" type="text" autocomplete="off"
placeholder="${placeholder ||
""}" style="font-size: 1em; width: 25em;" list=${list}>
<datalist id="${list}">
${options.map(d =>
Object.assign(html`<option>`, {
value: d
})
)}
</datalist>
<input type="reset">
</form>
`
});

form.output.remove();
return form;
}
Insert cell
bytes = (await import('@jimpick/bytes-iec@3.1.0-2')).default
Insert cell
hash = Generators.observe(notify => {
// https://observablehq.com/@jashkenas/url-querystrings-and-hash-parameters
const hashchange = () => notify(location.hash.replace('#', '') === '' ? undefined : location.hash.replace('#', ''));
hashchange();
addEventListener("hashchange", hashchange);
return () => removeEventListener("hashchange", hashchange);
})
Insert cell
md`## Full Miner List

Miner | Size | Active Deals
----- | ---- | ------------
${dealMiners.map(dealMiner => `${dealMiner.miner} | ${bytes(dealMiner.activeTotalSize, { mode: 'binary' })} | ${dealMiner.activeCount}\n`)}
`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more