Published
Edited
Aug 13, 2020
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.Int32Vector.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)),
],
[
"dealNumber",
"client",
"provider",
"pieceSize",
"startEpoch",
"endEpoch",
"sectorStartEpoch",
"slashEpoch",
"verifiedDeal"
]
)
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
focusedArrowDeals.scan(idx => {
result.push({
dealNumber: Uint32Array.from([dealNumber(idx)])[0],
client: `${client(idx)}`,
provider: `${provider(idx)}`,
pieceSize: Int32Array.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)
})
let sectorStart = Int32Array.from([sectorStartEpoch(idx)])[0]
if (sectorStart >= 0) {
sumPieceSize += Int32Array.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)
})
return { result, sumPieceSize }
}
Insert cell
miner = {
let miner
miner = 't01076'
return miner
}
Insert cell
Insert cell
md`# Focused Deals for Miner ${miner}

Height: ${selectedHeight}

Active Size: ${filteredFocusedDeals.sumPieceSize}

Deal # | Client | Miner | Piece Size | Sector Start | Start | End | Slash | Verified
--- | --- | --- | --- | --- | --- | --- | --- | ---
${filteredFocusedDeals.result.map(({dealNumber, client, provider, pieceSize, sectorStartEpoch, startEpoch, endEpoch, slashEpoch, verifiedDeal }) =>
`${dealNumber} | ${client} | ${provider} | ${pieceSize} | ${sectorStartEpoch} | ${startEpoch} | ${endEpoch} | ${slashEpoch} | ${verifiedDeal} \n`)}
`
Insert cell
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/calibration_api/0/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
import {autoSelect} from "@jashkenas/inputs"
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