curio web: Show basic balances in Actor Summary
This commit is contained in:
parent
25711c5ce4
commit
8e4ce10708
@ -33,6 +33,8 @@ type actorInfo struct {
|
|||||||
QualityAdjustedPower string
|
QualityAdjustedPower string
|
||||||
RawBytePower string
|
RawBytePower string
|
||||||
|
|
||||||
|
ActorBalance, ActorAvailable, WorkerBalance string
|
||||||
|
|
||||||
Deadlines []actorDeadline
|
Deadlines []actorDeadline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,9 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/blockstore"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,6 +42,8 @@ func (a *app) updateActor(ctx context.Context) error {
|
|||||||
api := a.workingApi
|
api := a.workingApi
|
||||||
a.rpcInfoLk.Unlock()
|
a.rpcInfoLk.Unlock()
|
||||||
|
|
||||||
|
stor := store.ActorStore(ctx, blockstore.NewReadCachedBlockstore(blockstore.NewAPIBlockstore(a.workingApi), ChainBlockCache))
|
||||||
|
|
||||||
if api == nil {
|
if api == nil {
|
||||||
log.Warnw("no working api yet")
|
log.Warnw("no working api yet")
|
||||||
return nil
|
return nil
|
||||||
@ -76,6 +81,16 @@ func (a *app) updateActor(ctx context.Context) error {
|
|||||||
return xerrors.Errorf("getting deadlines: %w", err)
|
return xerrors.Errorf("getting deadlines: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mact, err := api.StateGetActor(ctx, addr, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting actor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mas, err := miner.Load(stor, mact)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
outDls := []actorDeadline{}
|
outDls := []actorDeadline{}
|
||||||
|
|
||||||
for dlidx := range dls {
|
for dlidx := range dls {
|
||||||
@ -127,12 +142,31 @@ func (a *app) updateActor(ctx context.Context) error {
|
|||||||
|
|
||||||
outDls[pd.Index].Current = true
|
outDls[pd.Index].Current = true
|
||||||
|
|
||||||
|
avail, err := mas.AvailableBalance(mact.Balance)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting available balance: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mi, err := mas.Info()
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting miner info: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
wbal, err := api.WalletBalance(ctx, mi.Worker)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting worker balance: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
actorInfos = append(actorInfos, actorInfo{
|
actorInfos = append(actorInfos, actorInfo{
|
||||||
Address: addr.String(),
|
Address: addr.String(),
|
||||||
CLayers: cnames,
|
CLayers: cnames,
|
||||||
QualityAdjustedPower: types.DeciStr(p.MinerPower.QualityAdjPower),
|
QualityAdjustedPower: types.DeciStr(p.MinerPower.QualityAdjPower),
|
||||||
RawBytePower: types.DeciStr(p.MinerPower.RawBytePower),
|
RawBytePower: types.DeciStr(p.MinerPower.RawBytePower),
|
||||||
Deadlines: outDls,
|
Deadlines: outDls,
|
||||||
|
|
||||||
|
ActorBalance: types.FIL(mact.Balance).Short(),
|
||||||
|
ActorAvailable: types.FIL(avail).Short(),
|
||||||
|
WorkerBalance: types.FIL(wbal).Short(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>{{.ActorBalance}}</td>
|
||||||
|
<td>{{.ActorAvailable}}</td>
|
||||||
|
<td>{{.WorkerBalance}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
@ -97,6 +97,9 @@
|
|||||||
<th>Config Layers</th>
|
<th>Config Layers</th>
|
||||||
<th>QaP</th>
|
<th>QaP</th>
|
||||||
<th>Deadlines</th>
|
<th>Deadlines</th>
|
||||||
|
<th>Balance</th>
|
||||||
|
<th>Available</th>
|
||||||
|
<th>Worker</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody hx-get="/hapi/simpleinfo/actorsummary" hx-trigger="load,every 5s">
|
<tbody hx-get="/hapi/simpleinfo/actorsummary" hx-trigger="load,every 5s">
|
||||||
|
Loading…
Reference in New Issue
Block a user