Update datacap to parse tokens

This commit is contained in:
Geoff Stuart 2022-09-27 15:41:34 -04:00
parent c246366e7f
commit a604a60b22
3 changed files with 6 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin/v9/datacap"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
@ -33,7 +34,7 @@ func getDataCap(store adt.Store, ver actors.Version, root rootFunc, addr address
return false, big.Zero(), nil
}
return true, dcap, nil
return true, big.Div(dcap, datacap.DatacapGranularity), nil
}
func forEachCap(store adt.Store, ver actors.Version, root rootFunc, cb func(addr address.Address, dcap abi.StoragePower) error) error {
@ -47,6 +48,6 @@ func forEachCap(store adt.Store, ver actors.Version, root rootFunc, cb func(addr
if err != nil {
return err
}
return cb(a, dcap)
return cb(a, big.Div(dcap, datacap.DatacapGranularity))
})
}

2
go.mod
View File

@ -42,7 +42,7 @@ require (
github.com/filecoin-project/go-legs v0.4.4
github.com/filecoin-project/go-padreader v0.0.1
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220926220631-3e376503bf77
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220927193119-c1fd4fc0ad7f
github.com/filecoin-project/go-statemachine v1.0.2
github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/go-storedcounter v0.1.0

4
go.sum
View File

@ -343,8 +343,8 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220926220631-3e376503bf77 h1:NzifaBuMHnVvyfeNKxLJuXIt+/Jv1UNNC4o1tdLpcMM=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220926220631-3e376503bf77/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220927193119-c1fd4fc0ad7f h1:rhTiLLttRsO0ulpChrOFDuZx0KXChdbfxllaDpx8Fac=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220927193119-c1fd4fc0ad7f/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=