From 790a331ca5f99e913461e5b22c834b1433a9d31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 30 May 2022 16:19:57 +0200 Subject: [PATCH] bench: Support multiple piece infos in ParsePieceInfos --- cmd/lotus-bench/simple.go | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/cmd/lotus-bench/simple.go b/cmd/lotus-bench/simple.go index 4054b1dc4..21c90eb34 100644 --- a/cmd/lotus-bench/simple.go +++ b/cmd/lotus-bench/simple.go @@ -40,7 +40,7 @@ baga6ea4seaqpy7usqklokfx2vxuynmupslkeutzexe2uqurdg5vhtebhxqmpqmy 2048 > Run PreCommit1 -$ ./lotus-bench simple precommit1 --sector-size 2k /tmp/unsealed /tmp/sealed /tmp/cache baga6ea4seaqpy7usqklokfx2vxuynmupslkeutzexe2uqurdg5vhtebhxqmpqmy 2048 +$ ./lotus-bench simple precommit1 --sector-size 2k /tmp/unsealed /tmp/sealed /tmp/cache baga6ea4seaqpy7usqklokfx2vxuynmupslkeutzexe2uqurdg5vhtebhxqmpqmy 2048 PreCommit1 30.151666ms (66.33 KiB/s) eyJfbG90dXNfU2VhbFJhbmRvbW5lc3MiOiJBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB[...]== @@ -959,22 +959,32 @@ var simpleProveReplicaUpdate2 = &cli.Command{ } func ParsePieceInfos(cctx *cli.Context, firstArg int) ([]abi.PieceInfo, error) { - // supports only one for now - - c, err := cid.Parse(cctx.Args().Get(firstArg)) - if err != nil { - return nil, xerrors.Errorf("parse piece cid: %w", err) + args := cctx.Args().Len() - firstArg + if args%2 != 0 { + return nil, xerrors.Errorf("piece info argunemts need to be supplied in pairs") + } + if args < 2 { + return nil, xerrors.Errorf("need at least one piece info argument") } - psize, err := strconv.ParseUint(cctx.Args().Get(firstArg+1), 10, 64) - if err != nil { - return nil, xerrors.Errorf("parse piece size: %w", err) - } + out := make([]abi.PieceInfo, args/2) - return []abi.PieceInfo{ - { + for i := 0; i < args/2; i++ { + c, err := cid.Parse(cctx.Args().Get(firstArg + (i * 2))) + if err != nil { + return nil, xerrors.Errorf("parse piece cid: %w", err) + } + + psize, err := strconv.ParseUint(cctx.Args().Get(firstArg+(i*2)+1), 10, 64) + if err != nil { + return nil, xerrors.Errorf("parse piece size: %w", err) + } + + out[i] = abi.PieceInfo{ Size: abi.PaddedPieceSize(psize), PieceCID: c, - }, - }, nil + } + } + + return out, nil }