github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/publisher/filecoin_lotus/api/storagemarket/storagemarket.go (about) 1 package storagemarket 2 3 import ( 4 "strconv" 5 6 "github.com/filecoin-project/go-address" 7 "github.com/filecoin-project/go-state-types/abi" 8 big2 "github.com/filecoin-project/go-state-types/big" 9 "github.com/ipfs/go-cid" 10 ) 11 12 type StorageDealStatus uint64 13 14 const ( 15 // StorageDealUnknown means the current status of a deal is undefined 16 StorageDealUnknown = StorageDealStatus(iota) 17 18 // StorageDealProposalNotFound is a status returned in responses when the deal itself cannot 19 // be located 20 StorageDealProposalNotFound 21 22 // StorageDealProposalRejected is returned by a StorageProvider when it chooses not to accept 23 // a DealProposal 24 StorageDealProposalRejected 25 26 // StorageDealProposalAccepted indicates an intent to accept a storage deal proposal 27 StorageDealProposalAccepted 28 29 // StorageDealStaged means a deal has been published and data is ready to be put into a sector 30 StorageDealStaged 31 32 // StorageDealSealing means a deal is in a sector that is being sealed 33 StorageDealSealing 34 35 // StorageDealFinalizing means a deal is in a sealed sector and we're doing final 36 // housekeeping before marking it active 37 StorageDealFinalizing 38 39 // StorageDealActive means a deal is in a sealed sector and the miner is proving the data 40 // for the deal 41 StorageDealActive 42 43 // StorageDealExpired means a deal has passed its final epoch and is expired 44 StorageDealExpired 45 46 // StorageDealSlashed means the deal was in a sector that got slashed from failing to prove 47 StorageDealSlashed 48 49 // StorageDealRejecting means the Provider has rejected the deal, and will send a rejection response 50 StorageDealRejecting 51 52 // StorageDealFailing means something has gone wrong in a deal. Once data is cleaned up the deal will finalize on 53 // StorageDealError 54 StorageDealFailing 55 56 // StorageDealFundsReserved means we've deposited funds as necessary to create a deal, ready to move forward 57 StorageDealFundsReserved 58 59 // StorageDealCheckForAcceptance means the client is waiting for a provider to seal and publish a deal 60 StorageDealCheckForAcceptance 61 62 // StorageDealValidating means the provider is validating that deal parameters are good for a proposal 63 StorageDealValidating 64 65 // StorageDealAcceptWait means the provider is running any custom decision logic to decide whether or not to accept the deal 66 StorageDealAcceptWait 67 68 // StorageDealStartDataTransfer means data transfer is beginning 69 StorageDealStartDataTransfer 70 71 // StorageDealTransferring means data is being sent from the client to the provider via the data transfer module 72 StorageDealTransferring 73 74 // StorageDealWaitingForData indicates either a manual transfer 75 // or that the provider has not received a data transfer request from the client 76 StorageDealWaitingForData 77 78 // StorageDealVerifyData means data has been transferred and we are attempting to verify it against the PieceCID 79 StorageDealVerifyData 80 81 // StorageDealReserveProviderFunds means that provider is making sure it has adequate funds for the deal in the StorageMarketActor 82 StorageDealReserveProviderFunds 83 84 // StorageDealReserveClientFunds means that client is making sure it has adequate funds for the deal in the StorageMarketActor 85 StorageDealReserveClientFunds 86 87 // StorageDealProviderFunding means that the provider has deposited funds in the StorageMarketActor and it is waiting 88 // to see the funds appear in its balance 89 StorageDealProviderFunding 90 91 // StorageDealClientFunding means that the client has deposited funds in the StorageMarketActor and it is waiting 92 // to see the funds appear in its balance 93 StorageDealClientFunding 94 95 // StorageDealPublish means the deal is ready to be published on chain 96 StorageDealPublish 97 98 // StorageDealPublishing means the deal has been published but we are waiting for it to appear on chain 99 StorageDealPublishing 100 101 // StorageDealError means the deal has failed due to an error, and no further updates will occur 102 StorageDealError 103 104 // StorageDealProviderTransferAwaitRestart means the provider has restarted while data 105 // was being transferred from client to provider, and will wait for the client to 106 // resume the transfer 107 StorageDealProviderTransferAwaitRestart 108 109 // StorageDealClientTransferRestart means a storage deal data transfer from client to provider will be restarted 110 // by the client 111 StorageDealClientTransferRestart 112 113 // StorageDealAwaitingPreCommit means a deal is ready and must be pre-committed 114 StorageDealAwaitingPreCommit 115 116 // StorageDealTransferQueued means the data transfer request has been queued and will be executed soon. 117 StorageDealTransferQueued 118 ) 119 120 func (s StorageDealStatus) String() string { 121 str, ok := DealStates[s] 122 if ok { 123 return str 124 } 125 126 return strconv.Itoa(int(s)) 127 } 128 129 var DealStates = map[StorageDealStatus]string{ 130 StorageDealUnknown: "StorageDealUnknown", 131 StorageDealProposalNotFound: "StorageDealProposalNotFound", 132 StorageDealProposalRejected: "StorageDealProposalRejected", 133 StorageDealProposalAccepted: "StorageDealProposalAccepted", 134 StorageDealAcceptWait: "StorageDealAcceptWait", 135 StorageDealStartDataTransfer: "StorageDealStartDataTransfer", 136 StorageDealStaged: "StorageDealStaged", 137 StorageDealAwaitingPreCommit: "StorageDealAwaitingPreCommit", 138 StorageDealSealing: "StorageDealSealing", 139 StorageDealActive: "StorageDealActive", 140 StorageDealExpired: "StorageDealExpired", 141 StorageDealSlashed: "StorageDealSlashed", 142 StorageDealRejecting: "StorageDealRejecting", 143 StorageDealFailing: "StorageDealFailing", 144 StorageDealFundsReserved: "StorageDealFundsReserved", 145 StorageDealCheckForAcceptance: "StorageDealCheckForAcceptance", 146 StorageDealValidating: "StorageDealValidating", 147 StorageDealTransferring: "StorageDealTransferring", 148 StorageDealWaitingForData: "StorageDealWaitingForData", 149 StorageDealVerifyData: "StorageDealVerifyData", 150 StorageDealReserveProviderFunds: "StorageDealReserveProviderFunds", 151 StorageDealReserveClientFunds: "StorageDealReserveClientFunds", 152 StorageDealProviderFunding: "StorageDealProviderFunding", 153 StorageDealClientFunding: "StorageDealClientFunding", 154 StorageDealPublish: "StorageDealPublish", 155 StorageDealPublishing: "StorageDealPublishing", 156 StorageDealError: "StorageDealError", 157 StorageDealFinalizing: "StorageDealFinalizing", 158 StorageDealClientTransferRestart: "StorageDealClientTransferRestart", 159 StorageDealProviderTransferAwaitRestart: "StorageDealProviderTransferAwaitRestart", 160 StorageDealTransferQueued: "StorageDealTransferQueued", 161 } 162 163 type DataRef struct { 164 TransferType string 165 Root cid.Cid 166 167 PieceCid *cid.Cid // Optional for non-manual transfer, will be recomputed from the data if not given 168 PieceSize abi.UnpaddedPieceSize // Optional for non-manual transfer, will be recomputed from the data if not given 169 RawBlockSize uint64 // Optional: used as the denominator when calculating transfer % 170 } 171 172 type StorageAsk struct { 173 // Price per GiB / Epoch 174 Price big2.Int 175 VerifiedPrice big2.Int 176 177 MinPieceSize abi.PaddedPieceSize 178 MaxPieceSize abi.PaddedPieceSize 179 Miner address.Address 180 Timestamp int64 181 Expiry int64 182 SeqNo uint64 183 }