Published
Edited
Sep 18, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// chainFetch(2)
Insert cell
Insert cell
chainPopulateResult = chainPopulate(1)
Insert cell
state = chainPopulateResult.states[0]
Insert cell
Insert cell
// {
// const power = await state.t04.get()
// const claims = await power.Claims.get()
// const minersAddrs = (await claims.toArray()).filter(d => +d.RawBytePower > 0).map(d => d.Address)
// const miners = asyncPool(5, minersAddrs, async address => {
// return await state[address].get()
// })
// return miners
// }
Insert cell
Insert cell
// GetMinerActors({limit: 2})
Insert cell
Insert cell
// claims = GetPowerClaims({minRawBytePower: 0})
Insert cell
// claims.sort((a, b) => - +a.RawBytePower + +b.RawBytePower)
Insert cell
GetPowerClaims = async (args = {}) => {
const {tipsetCid, minRawBytePower} = args
const tipset = await Tipset.FromCid(tipsetCid || await fetchLastBlockHash())
const state = await tipset.ParentStateRoot.get()
const power = await state.t04.get()
const claims = await power.Claims.get()
return (await claims.values()).filter(d => +d.RawBytePower > (minRawBytePower || 0))
}
Insert cell
Insert cell
// tip = await Tipset.FromCid(await fetchLastBlockHash())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// class Deadlines extends CidObj {
// async resolve() {
// const data = await fetchObj(this._cid, 'storageMinerActor.Deadlines')
// Object.assign(this, data)
// this._status = 'done'
// return this
// }
// }
Insert cell
Insert cell
{
const miner = await state['t01475'].Head.get()
await Promise.all([
miner.Info.get(),
miner.PreCommittedSectors.get(),
miner.AllocatedSectors.get(),
miner.Sectors.get(),
miner.PreCommittedSectorsExpiry.get()
])
const deadlines = await miner.Deadlines.get()
const dues = await Promise.all(deadlines.Due.map(d => d.get()))
return miner
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fetchHead()
Insert cell
Insert cell
// fetchLastBlockHash()
Insert cell
Insert cell
Insert cell
Insert cell
// fetchObj = async (cidObj, type) => {
// const hash = typeof cidObj === 'string' ? cidObj : cidObj['/']
// if (!cids[hash]) {
// mutable cids = {...cids, [hash]: await _fetchObj(cidObj, type)}
// }
// return cids[hash]
// }
Insert cell
Insert cell
Insert cell
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