bench: Support multiple piece infos in ParsePieceInfos
This commit is contained in:
parent
e148663155
commit
790a331ca5
@ -959,22 +959,32 @@ var simpleProveReplicaUpdate2 = &cli.Command{
|
||||
}
|
||||
|
||||
func ParsePieceInfos(cctx *cli.Context, firstArg int) ([]abi.PieceInfo, error) {
|
||||
// supports only one for now
|
||||
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")
|
||||
}
|
||||
|
||||
c, err := cid.Parse(cctx.Args().Get(firstArg))
|
||||
out := make([]abi.PieceInfo, args/2)
|
||||
|
||||
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+1), 10, 64)
|
||||
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)
|
||||
}
|
||||
|
||||
return []abi.PieceInfo{
|
||||
{
|
||||
out[i] = abi.PieceInfo{
|
||||
Size: abi.PaddedPieceSize(psize),
|
||||
PieceCID: c,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user