Merge pull request #1786 from filecoin-project/asr/clideal
Prevent client list-deals from crashing
This commit is contained in:
commit
f99c5416ce
@ -501,17 +501,28 @@ var clientListDeals = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var deals []deal
|
var deals []deal
|
||||||
for idx := range localDeals {
|
for _, v := range localDeals {
|
||||||
onChain, err := api.StateMarketStorageDeal(ctx, localDeals[idx].DealID, head.Key())
|
if v.DealID == 0 {
|
||||||
|
deals = append(deals, deal{
|
||||||
|
LocalDeal: v,
|
||||||
|
OnChainDealState: market.DealState{
|
||||||
|
SectorStartEpoch: -1,
|
||||||
|
LastUpdatedEpoch: -1,
|
||||||
|
SlashEpoch: -1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
onChain, err := api.StateMarketStorageDeal(ctx, v.DealID, head.Key())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
deals = append(deals, deal{
|
deals = append(deals, deal{
|
||||||
LocalDeal: localDeals[idx],
|
LocalDeal: v,
|
||||||
OnChainDealState: onChain.State,
|
OnChainDealState: onChain.State,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
||||||
fmt.Fprintf(w, "DealCid\tDealId\tProvider\tState\tOn Chain?\tSlashed?\tPieceCID\tSize\tPrice\tDuration\tMessage\n")
|
fmt.Fprintf(w, "DealCid\tDealId\tProvider\tState\tOn Chain?\tSlashed?\tPieceCID\tSize\tPrice\tDuration\tMessage\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user