diff --git a/api/api_full.go b/api/api_full.go index 80edf385b..aa4dbea43 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -9,6 +9,7 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" @@ -153,7 +154,7 @@ type Import struct { type DealInfo struct { ProposalCid cid.Cid - State DealState + State storagemarket.StorageDealStatus Provider address.Address PieceRef []byte // cid bytes diff --git a/api/test/deals.go b/api/test/deals.go index bb6129838..8ddbb0cbe 100644 --- a/api/test/deals.go +++ b/api/test/deals.go @@ -13,7 +13,7 @@ import ( logging "github.com/ipfs/go-log/v2" - "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/impl" @@ -88,17 +88,17 @@ loop: t.Fatal(err) } switch di.State { - case api.DealRejected: + case storagemarket.StorageDealProposalRejected: t.Fatal("deal rejected") - case api.DealFailed: + case storagemarket.StorageDealFailing: t.Fatal("deal failed") - case api.DealError: + case storagemarket.StorageDealError: t.Fatal("deal errored") - case api.DealComplete: + case storagemarket.StorageDealActive: fmt.Println("COMPLETE", di) break loop } - fmt.Println("Deal state: ", api.DealStates[di.State]) + fmt.Println("Deal state: ", storagemarket.DealStates[di.State]) time.Sleep(time.Second / 2) } diff --git a/api/types.go b/api/types.go index cd2717bbd..449a3ae79 100644 --- a/api/types.go +++ b/api/types.go @@ -6,36 +6,6 @@ import ( ma "github.com/multiformats/go-multiaddr" ) -type DealState = uint64 - -const ( - DealUnknown = DealState(iota) - DealRejected // Provider didn't like the proposal - DealAccepted // Proposal accepted, data moved - DealStaged // Data put into the sector - DealSealing // Data in process of being sealed - - DealFailed - DealComplete - - // Internal - - DealError // deal failed with an unexpected error - - DealNoUpdate = DealUnknown -) - -var DealStates = []string{ - "DealUnknown", - "DealRejected", - "DealAccepted", - "DealStaged", - "DealSealing", - "DealFailed", - "DealComplete", - "DealError", -} - // TODO: check if this exists anywhere else type MultiaddrSlice []ma.Multiaddr diff --git a/cli/client.go b/cli/client.go index 34208318f..bbc328169 100644 --- a/cli/client.go +++ b/cli/client.go @@ -13,7 +13,7 @@ import ( "gopkg.in/urfave/cli.v2" "github.com/filecoin-project/go-address" - lapi "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/go-fil-markets/storagemarket" actors "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" ) @@ -359,7 +359,7 @@ var clientListDeals = &cli.Command{ w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0) fmt.Fprintf(w, "DealCid\tProvider\tState\tPieceRef\tSize\tPrice\tDuration\n") for _, d := range deals { - fmt.Fprintf(w, "%s\t%s\t%s\t%x\t%d\t%s\t%d\n", d.ProposalCid, d.Provider, lapi.DealStates[d.State], d.PieceRef, d.Size, d.PricePerEpoch, d.Duration) + fmt.Fprintf(w, "%s\t%s\t%s\t%x\t%d\t%s\t%d\n", d.ProposalCid, d.Provider, storagemarket.DealStates[d.State], d.PieceRef, d.Size, d.PricePerEpoch, d.Duration) } return w.Flush() }, diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index 18b31c9b6..1fe4084de 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -293,7 +293,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin MinerDeal: storagemarket.MinerDeal{ Proposal: *proposal, ProposalCid: proposalCid, - State: lapi.DealComplete, + State: storagemarket.StorageDealActive, Ref: proposalCid, // TODO: This is super wrong, but there // are no params for CommP CIDs, we can't recover unixfs cid easily, // and this isn't even used after the deal enters Complete state diff --git a/lotuspond/front/src/Client.js b/lotuspond/front/src/Client.js index 70aabfd6f..aa63e8a23 100644 --- a/lotuspond/front/src/Client.js +++ b/lotuspond/front/src/Client.js @@ -1,68 +1,92 @@ -import React from 'react'; -import Address from "./Address"; -import Window from "./Window"; -import Fil from "./Fil"; +import React from 'react' +import Address from './Address' +import Window from './Window' +import Fil from './Fil' const dealStates = [ - "Unknown", - "Rejected", - "Accepted", - "Staged", - "Sealing", - "Failed", - "Complete", - "Error", -] + 'Unknown', + 'ProposalNotFound', + 'ProposalRejected', + 'ProposalAccepted', + 'Staged', + 'Sealing', + 'ProposalSigned', + 'Published', + 'Committed', + 'Active', + 'Failing', + 'Recovering', + 'Expired', + 'NotFound', + 'Validating', + 'Transferring', + 'VerifyData', + 'Publishing', + 'Error' +] class Client extends React.Component { constructor(props) { super(props) this.state = { - miners: ["t0101"], - ask: {Price: "1000000000"}, // 2x min default ask to account for bin packing (could also do the math correctly below, but..) + miners: ['t0101'], + ask: { Price: '1000000000' }, // 2x min default ask to account for bin packing (could also do the math correctly below, but..) kbs: 1, blocks: 12, total: 36000, - miner: "t0101", + miner: 't0101', deals: [], - blockDelay: 10, + blockDelay: 10 } } async componentDidMount() { let ver = await this.props.client.call('Filecoin.Version', []) - this.setState({blockDelay: ver.BlockDelay}) + this.setState({ blockDelay: ver.BlockDelay }) this.getDeals() setInterval(this.getDeals, 1325) } getDeals = async () => { - let miners = await this.props.client.call('Filecoin.StateListMiners', [null]) + let miners = await this.props.client.call('Filecoin.StateListMiners', [ + null + ]) let deals = await this.props.client.call('Filecoin.ClientListDeals', []) miners.sort() - this.setState({deals, miners}) + this.setState({ deals, miners }) } - update = (name) => (e) => this.setState({ [name]: e.target.value }); + update = name => e => this.setState({ [name]: e.target.value }) makeDeal = async () => { - let perBlk = this.state.ask.Price * this.state.kbs * 1000 / (1 << 30) * 2 + let perBlk = + ((this.state.ask.Price * this.state.kbs * 1000) / (1 << 30)) * 2 - let file = await this.props.pondClient.call('Pond.CreateRandomFile', [this.state.kbs * 1000]) // 1024 won't fit in 1k blocks :( + let file = await this.props.pondClient.call('Pond.CreateRandomFile', [ + this.state.kbs * 1000 + ]) // 1024 won't fit in 1k blocks :( let cid = await this.props.client.call('Filecoin.ClientImport', [file]) - let dealcid = await this.props.client.call('Filecoin.ClientStartDeal', [cid, this.state.miner, `${Math.round(perBlk)}`, Number(this.state.blocks)]) - console.log("deal cid: ", dealcid) + let dealcid = await this.props.client.call('Filecoin.ClientStartDeal', [ + cid, + this.state.miner, + `${Math.round(perBlk)}`, + Number(this.state.blocks) + ]) + console.log('deal cid: ', dealcid) } - retrieve = (deal) => async () => { + retrieve = deal => async () => { console.log(deal) - let client = await this.props.client.call('Filecoin.WalletDefaultAddress', []) + let client = await this.props.client.call( + 'Filecoin.WalletDefaultAddress', + [] + ) let order = { Root: deal.PieceRef, @@ -74,7 +98,10 @@ class Client extends React.Component { Miner: deal.Miner } - await this.props.client.call('Filecoin.ClientRetrieve', [order, '/dev/null']) + await this.props.client.call('Filecoin.ClientRetrieve', [ + order, + '/dev/null' + ]) } render() { @@ -82,41 +109,111 @@ class Client extends React.Component { let total = perBlk * this.state.blocks let days = (this.state.blocks * this.state.blockDelay) / 60 / 60 / 24 - let dealMaker =