From 8f121ab0ec1c67e65d5429d330bce8e326496d5d Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 8 Apr 2022 00:36:10 +0300 Subject: [PATCH] patch agen to deal with v8 deal proposals --- chain/actors/agen/main.go | 1 + chain/actors/builtin/market/state.go.template | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/chain/actors/agen/main.go b/chain/actors/agen/main.go index d07c039dd..6c5952f2e 100644 --- a/chain/actors/agen/main.go +++ b/chain/actors/agen/main.go @@ -110,6 +110,7 @@ func generateState(actDir string) error { err := tpl.Execute(&b, map[string]interface{}{ "v": version, "import": getVersionImports()[version], + "isv8": version == 8, }) if err != nil { return err diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index e8272276c..df561be49 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -231,7 +231,28 @@ func (s *dealProposals{{.v}}) array() adt.Array { } func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal { +{{if .isv8 }} + label, err := v8.Label.ToString() + if err != nil { + bs, _ := v8.Label.ToBytes() + label = string(bs) + } + return DealProposal{ + PieceCID: v8.PieceCID, + PieceSize: v8.PieceSize, + VerifiedDeal: v8.VerifiedDeal, + Client: v8.Client, + Provider: v8.Provider, + Label: label, + StartEpoch: v8.StartEpoch, + EndEpoch: v8.EndEpoch, + StoragePricePerEpoch: v8.StoragePricePerEpoch, + ProviderCollateral: v8.ProviderCollateral, + ClientCollateral: v8.ClientCollateral, + } +{{else}} return (DealProposal)(v{{.v}}) +{{end}} } func (s *state{{.v}}) GetState() interface{} {