Skip to content

Commit

Permalink
Merge pull request #329 from filecoin-project/fix/tanlang/adapt-deal-…
Browse files Browse the repository at this point in the history
…filter-output-to-CIDgravity

fix: adapt deal filter format to CIDgravity / 修改 dealfilter 的实现, 以兼容 CIDgravity
  • Loading branch information
simlecode authored May 17, 2023
2 parents ddcfbc2 + daaee6c commit 8cb7c87
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
14 changes: 10 additions & 4 deletions dealfilter/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ func CliStorageDealFilter(cfg *config.MarketConfig) config.StorageDealFilter {
}

d := struct {
IsOffline bool
vsTypes.ClientDealProposal
DealType string
Agent string
FormatVersion string
IsOffline bool
ClientDealProposal vsTypes.ClientDealProposal
FastRetrieval bool
TransferType string
DealType string
Agent string
}{
IsOffline: isOffline,
ClientDealProposal: deal.ClientDealProposal,
DealType: "storage",
Agent: "venus-market",
FormatVersion: "1.0.0",
FastRetrieval: deal.FastRetrieval,
TransferType: deal.Ref.TransferType,
}
return runDealFilter(ctx, pCfg.Filter, d)
}
Expand Down
45 changes: 25 additions & 20 deletions docs/zh/订单过滤器.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,29 @@
```json
{
"IsOffline": false,
"Proposal": {
"PieceCID": {
"/": "baga6ea4seaqihx2pxanewwxvqwgeyrcmal7aomucelef52vhqy7qaarciamaqoq"
},
"PieceSize": 2048,
"VerifiedDeal": false,
"Client": "f3r3hr3xl27unpefvipve2f4hlfvdnq3forgr253z6dqahufvanatdandxm74zikheccvx74ys7by5vzafq2va",
"Provider": "f01000",
"Label": "bafk2bzacebiupsywspqnsvc5v7ing74i3u4y3r7wtgjioor7pqn3cxopq7lo4",
"StartEpoch": 18171,
"EndEpoch": 536571,
"StoragePricePerEpoch": "1",
"ProviderCollateral": "0",
"ClientCollateral": "0"
},
"ClientSignature": {
"Type": 2,
"Data": "oEnUUL1WejrLawl3sP9o/TZYRZgPYA86xmF3RMQt5bPQJbrK/5x3UXYxeUKoIDMjE96fA1GSqfrE14tFl/nMyatPLUvzzZ0ulsPTQVwfb54Mgx0yBSMYTf/O8Bg09MNq"
"FormatVersion": "1.0.0",
"FastRetrieval": false,
"TransferType" : "manual",
"ClientDealProposal":{
"Proposal": {
"PieceCID": {
"/": "baga6ea4seaqihx2pxanewwxvqwgeyrcmal7aomucelef52vhqy7qaarciamaqoq"
},
"PieceSize": 2048,
"VerifiedDeal": false,
"Client": "f3r3hr3xl27unpefvipve2f4hlfvdnq3forgr253z6dqahufvanatdandxm74zikheccvx74ys7by5vzafq2va",
"Provider": "f01000",
"Label": "bafk2bzacebiupsywspqnsvc5v7ing74i3u4y3r7wtgjioor7pqn3cxopq7lo4",
"StartEpoch": 18171,
"EndEpoch": 536571,
"StoragePricePerEpoch": "1",
"ProviderCollateral": "0",
"ClientCollateral": "0"
},
"ClientSignature": {
"Type": 2,
"Data": "oEnUUL1WejrLawl3sP9o/TZYRZgPYA86xmF3RMQt5bPQJbrK/5x3UXYxeUKoIDMjE96fA1GSqfrE14tFl/nMyatPLUvzzZ0ulsPTQVwfb54Mgx0yBSMYTf/O8Bg09MNq"
},
},
"DealType": "storage",
"Agent": "venus-market"
Expand Down Expand Up @@ -95,7 +100,7 @@ Filter = "exit 0"
- 例子: 只接受来自 `f01000` 的订单

```toml
Filter = "jq -r '.Proposal.Provider' | grep -q '^f01000$'"
Filter = "jq -r '.ClientDealProposal.Proposal.Provider' | grep -q '^f01000$'"
```

- 例子: 使用 `python` 脚本
Expand All @@ -114,7 +119,7 @@ try:
json_str = sys.stdin.read()
data = json.loads(json_str)

if data['Proposal']['PieceSize'] < 2048:
if data["ClientDealProposal"]['Proposal']['PieceSize'] < 2048:
print("")
sys.exit(0)
else:
Expand Down
2 changes: 2 additions & 0 deletions storageprovider/deal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ func (storageDealPorcess *StorageDealProcessImpl) SendSignedResponse(ctx context
// StorageDealRejecting(RejectDeal)->StorageDealFailing(FailDeal)
func (storageDealPorcess *StorageDealProcessImpl) HandleReject(ctx context.Context, deal *types.MinerDeal, event storagemarket.StorageDealStatus, err error) error {
storageDealPorcess.eventPublisher.Publish(storagemarket.ProviderEventDealRejected, deal)
log.Infof("deal rejected (proposal cid: %s ): %s", deal.ProposalCid, err)

deal.State = event
deal.Message = err.Error()

Expand Down

0 comments on commit 8cb7c87

Please sign in to comment.