http://www.7klian.com

能干 Filecoin:Lotus真实数据处理惩罚之Provider处理惩罚存储

函数内容如下: node?:=?environment.Node()

if?proposal.Provider?!=?environment.Address()?{return?ctx.Trigger(storagemarket.ProviderEventDealRejected,?xerrors.Errorf("incorrect?provider?for?deal")) } 查抄生意业务指定的高度是否正确。假如不正确,则发送拒绝事件。 if?height?>?proposal.StartEpoch-environment.DealAcceptanceBuffer()?{return?ctx.Trigger(storagemarket.ProviderEventDealRejected,?xerrors.Errorf("deal?start?epoch?is?too?soon?or?deal?already?expired")) } 查抄用度是否OK,假如不OK,则发送拒绝事件。 minPrice?:=?big.Div(big.Mul(environment.Ask().Price,?abi.NewTokenAmount(int64(proposal.PieceSize))),?abi.NewTokenAmount(1<<30)) if?proposal.StoragePricePerEpoch.LessThan(minPrice)?{return?ctx.Trigger(storagemarket.ProviderEventDealRejected,xerrors.Errorf("storage?price?per?epoch?less?than?asking?price:?%s?<?%s",?proposal.StoragePricePerEpoch,?minPrice)) } 查抄生意业务的巨细是否匹配。假如不匹配,则发送拒绝事件。 if?proposal.PieceSize?<?environment.Ask().MinPieceSize?{return?ctx.Trigger(storagemarket.ProviderEventDealRejected,xerrors.Errorf("piece?size?less?than?minimum?required?size:?%d?<?%d",?proposal.PieceSize,?environment.Ask().MinPieceSize)) }

当状态机收到这个事件后,颠末事件处理惩罚器把状态从 StorageDealPublishing 修改为 StorageDealStaged,从而挪用其处理惩罚函数 HandoffDeal 开始扇区密封处理惩罚。同时,在挪用处理惩罚函数之前,通过 Action 函数,修改矿工生意业务工具的 ConnectionClosed 和 DealID 属性。 return?environment.Node().WaitForMessage(ctx.Context(),?*deal.PublishCid,?func(code?exitcode.ExitCode,?retBytes?[]byte,?err?error)?error?{if?err?!=?nil?{return?ctx.Trigger(storagemarket.ProviderEventDealPublishError,?xerrors.Errorf("PublishStorageDeals?errored:?%w",?err))}if?code?!=?exitcode.Ok?{return?ctx.Trigger(storagemarket.ProviderEventDealPublishError,?xerrors.Errorf("PublishStorageDeals?exit?code:?%s",?code.String()))}var?retval?market.PublishStorageDealsReturnerr?=?retval.UnmarshalCBOR(bytes.NewReader(retBytes))if?err?!=?nil?{return?ctx.Trigger(storagemarket.ProviderEventDealPublishError,?xerrors.Errorf("PublishStorageDeals?error?unmarshalling?result:?%w",?err))}

if?err?!=?nil?{return?ctx.Trigger(storagemarket.ProviderEventFileStoreErrored,?xerrors.Errorf("reading?piece?at?path?%s:?%w",?deal.PiecePath,?err)) } 利用碎片文件流生成碎片流。 paddedReader,?paddedSize?:=?padreader.New(file,?uint64(file.Size())) 挪用 Lotus Provider 适配器工具的 OnDealComplete 要领,通知生意业务已经完成,从而把碎片插手某个扇区中。 err?=?environment.Node().OnDealComplete(ctx.Context(),storagemarket.MinerDeal{Client:deal.Client,ClientDealProposal:?deal.ClientDealProposal,ProposalCid:deal.ProposalCid,State:deal.State,Ref:deal.Ref,DealID:deal.DealID,FastRetrieval:deal.FastRetrieval,PiecePath:filestore.Path(environment.FileStore().Filename(deal.PiecePath)), },paddedSize,paddedReader, )

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!

相关文章阅读