remove found boolean and use a pointer

This commit is contained in:
Anton Evangelatov 2021-03-30 17:12:49 +03:00
parent b661f51976
commit adaf3a2753

View File

@ -20,23 +20,20 @@ func InspectDealCmd(ctx context.Context, api lapi.FullNode, proposalCid string,
return err return err
} }
var di lapi.DealInfo var di *lapi.DealInfo
found := false for i, cdi := range deals {
for _, cdi := range deals {
if proposalCid != "" && cdi.ProposalCid.String() == proposalCid { if proposalCid != "" && cdi.ProposalCid.String() == proposalCid {
di = cdi di = &deals[i]
found = true
break break
} }
if dealId != 0 && int(cdi.DealID) == dealId { if dealId != 0 && int(cdi.DealID) == dealId {
di = cdi di = &deals[i]
found = true
break break
} }
} }
if !found { if di == nil {
if proposalCid != "" { if proposalCid != "" {
return fmt.Errorf("cannot find deal with proposal cid: %s", proposalCid) return fmt.Errorf("cannot find deal with proposal cid: %s", proposalCid)
} }
@ -51,7 +48,7 @@ func InspectDealCmd(ctx context.Context, api lapi.FullNode, proposalCid string,
return nil return nil
} }
func renderDeal(di lapi.DealInfo) { func renderDeal(di *lapi.DealInfo) {
color.Blue("Deal ID: %d\n", int(di.DealID)) color.Blue("Deal ID: %d\n", int(di.DealID))
color.Blue("Proposal CID: %s\n\n", di.ProposalCid.String()) color.Blue("Proposal CID: %s\n\n", di.ProposalCid.String())