Cleanup math

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera
2019-12-10 20:53:39 +01:00
parent 0fa20f6074
commit bfdfd4023e
2 changed files with 16 additions and 7 deletions
+6 -2
View File
@@ -6,8 +6,8 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"github.com/filecoin-project/lotus/chain/types"
"io/ioutil"
"math/big"
"math/rand"
"os"
"path/filepath"
@@ -23,6 +23,7 @@ import (
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
)
@@ -361,5 +362,8 @@ func main() {
}
func bps(data uint64, d time.Duration) string {
return lcli.SizeStr(types.BigDiv(types.BigMul(types.NewInt(data), types.NewInt(uint64(time.Second))), types.NewInt(uint64(d)))) + "/s"
bdata := new(big.Int).SetUint64(data)
bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds()))
bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds()))
return lcli.SizeStr(types.BigInt{bps}) + "/s"
}