@@ -20,7 +20,7 @@ type service struct {
2020
2121type storeResult struct {
2222 Cids []cid.Cid
23- DealConfigs []deals.DealConfig
23+ FailedDeals []deals.DealConfig
2424 Err error
2525}
2626
@@ -33,12 +33,12 @@ func store(ctx context.Context, dealModule *deals.DealModule, storeParams *pb.St
3333 EpochPrice : types .NewInt (dealConfig .GetEpochPrice ()),
3434 }
3535 }
36- cids , dealConfigs , err := dealModule .Store (ctx , storeParams .GetAddress (), reader , dealConfigs , storeParams .GetDuration ())
36+ cids , failedDeals , err := dealModule .Store (ctx , storeParams .GetAddress (), reader , dealConfigs , storeParams .GetDuration ())
3737 if err != nil {
3838 ch <- storeResult {Err : err }
3939 return
4040 }
41- ch <- storeResult {Cids : cids , DealConfigs : dealConfigs }
41+ ch <- storeResult {Cids : cids , FailedDeals : failedDeals }
4242}
4343
4444func (s * service ) AvailableAsks (ctx context.Context , req * pb.AvailableAsksRequest ) (* pb.AvailableAsksReply , error ) {
@@ -75,7 +75,7 @@ func (s *service) Store(srv pb.API_StoreServer) error {
7575 case * pb.StoreRequest_StoreParams :
7676 storeParams = payload .StoreParams
7777 default :
78- return status .Errorf (codes .InvalidArgument , "expexted StoreParams for StoreRequest.Payload but got %T" , payload )
78+ return status .Errorf (codes .InvalidArgument , "expected StoreParams for StoreRequest.Payload but got %T" , payload )
7979 }
8080
8181 reader , writer := io .Pipe ()
@@ -113,12 +113,12 @@ func (s *service) Store(srv pb.API_StoreServer) error {
113113 replyCids [i ] = cid .String ()
114114 }
115115
116- replyDealConfigs := make ([]* pb.DealConfig , len (storeResult .DealConfigs ))
117- for i , dealConfig := range storeResult .DealConfigs {
118- replyDealConfigs [i ] = & pb.DealConfig {Miner : dealConfig .Miner , EpochPrice : dealConfig .EpochPrice .Uint64 ()}
116+ replyFailedDeals := make ([]* pb.DealConfig , len (storeResult .FailedDeals ))
117+ for i , dealConfig := range storeResult .FailedDeals {
118+ replyFailedDeals [i ] = & pb.DealConfig {Miner : dealConfig .Miner , EpochPrice : dealConfig .EpochPrice .Uint64 ()}
119119 }
120120
121- return srv .SendAndClose (& pb.StoreReply {Cids : replyCids , DealConfigs : replyDealConfigs })
121+ return srv .SendAndClose (& pb.StoreReply {Cids : replyCids , FailedDeals : replyFailedDeals })
122122}
123123
124124func (s * service ) Watch (req * pb.WatchRequest , srv pb.API_WatchServer ) error {
@@ -135,23 +135,18 @@ func (s *service) Watch(req *pb.WatchRequest, srv pb.API_WatchServer) error {
135135 return err
136136 }
137137
138- for {
139- update , ok := <- ch
140- if ok == false {
141- break
142- } else {
143- dealInfo := & pb.DealInfo {
144- ProposalCid : update .ProposalCid .String (),
145- StateID : update .StateID ,
146- StateName : update .StateName ,
147- Miner : update .Miner ,
148- PieceRef : update .PieceRef ,
149- Size : update .Size ,
150- PricePerEpoch : update .PricePerEpoch .Uint64 (),
151- Duration : update .Duration ,
152- }
153- srv .Send (& pb.WatchReply {DealInfo : dealInfo })
138+ for update := range ch {
139+ dealInfo := & pb.DealInfo {
140+ ProposalCid : update .ProposalCid .String (),
141+ StateID : update .StateID ,
142+ StateName : update .StateName ,
143+ Miner : update .Miner ,
144+ PieceRef : update .PieceRef ,
145+ Size : update .Size ,
146+ PricePerEpoch : update .PricePerEpoch .Uint64 (),
147+ Duration : update .Duration ,
154148 }
149+ srv .Send (& pb.WatchReply {DealInfo : dealInfo })
155150 }
156151 return nil
157152}
0 commit comments