Get some deals to work
This commit is contained in:
parent
68c2d4f58a
commit
37721b2a22
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/address"
|
"github.com/filecoin-project/lotus/chain/address"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/lib/padreader"
|
||||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -218,8 +219,8 @@ func (p *Provider) staged(ctx context.Context, deal MinerDeal) (func(*MinerDeal)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("getting unixfs file size: %w", err)
|
return nil, xerrors.Errorf("getting unixfs file size: %w", err)
|
||||||
}
|
}
|
||||||
if uint64(size) != deal.Proposal.PieceSize {
|
if padreader.PaddedSize(uint64(size)) != deal.Proposal.PieceSize {
|
||||||
return nil, xerrors.Errorf("deal.Proposal.PieceSize didn't match unixfs file size")
|
return nil, xerrors.Errorf("deal.Proposal.PieceSize didn't match padded unixfs file size")
|
||||||
}
|
}
|
||||||
|
|
||||||
sectorID, err := p.secb.AddUnixfsPiece(deal.Ref, uf, deal.DealID)
|
sectorID, err := p.secb.AddUnixfsPiece(deal.Ref, uf, deal.DealID)
|
||||||
|
@ -21,7 +21,7 @@ class Client extends React.Component {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
miners: ["t0101"],
|
miners: ["t0101"],
|
||||||
ask: {Price: "500000000"},
|
ask: {Price: "1000000000"}, // 2x min default ask to account for bin packing (could also do the math correctly below, but..)
|
||||||
|
|
||||||
kbs: 1,
|
kbs: 1,
|
||||||
blocks: 12,
|
blocks: 12,
|
||||||
@ -52,7 +52,7 @@ class Client extends React.Component {
|
|||||||
update = (name) => (e) => this.setState({ [name]: e.target.value });
|
update = (name) => (e) => this.setState({ [name]: e.target.value });
|
||||||
|
|
||||||
makeDeal = async () => {
|
makeDeal = async () => {
|
||||||
let perBlk = this.state.ask.Price * this.state.kbs * 1000 / (1 << 30)
|
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 cid = await this.props.client.call('Filecoin.ClientImport', [file])
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||||
|
"github.com/filecoin-project/lotus/lib/padreader"
|
||||||
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/storage/sector"
|
"github.com/filecoin-project/lotus/storage/sector"
|
||||||
@ -172,7 +173,9 @@ func (st *SectorBlocks) AddUnixfsPiece(ref cid.Cid, r UnixfsReader, dealID uint6
|
|||||||
intermediate: st.intermediate,
|
intermediate: st.intermediate,
|
||||||
}
|
}
|
||||||
|
|
||||||
return st.Store.AddPiece(refst.pieceRef, uint64(size), refst, dealID)
|
pr, psize := padreader.New(r, uint64(size))
|
||||||
|
|
||||||
|
return st.Store.AddPiece(refst.pieceRef, psize, pr, dealID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *SectorBlocks) List() (map[cid.Cid][]api.SealedRef, error) {
|
func (st *SectorBlocks) List() (map[cid.Cid][]api.SealedRef, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user