WIP annoying errors

This commit is contained in:
zenground0 2022-04-07 17:33:03 -06:00 committed by vyzo
parent 339b7db2b7
commit 124fe26492
9 changed files with 217 additions and 18 deletions

View File

@ -189,8 +189,34 @@ func (s *dealStates{{.v}}) array() adt.Array {
return s.Array
}
func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState {
return (DealState)(v{{.v}})
func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) (DealState, error) {
{{if (le .v 7)}}
label, err := labelFromGoString(v{{.v}}.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
{{else}}
label := v{{.v}}.Label
{{end}}
return DealProposal{
PieceCID : v{{.v}}.PieceCID,
PieceSize : v{{.v}}.PieceSize,
VerifiedDeal :v{{.v}}.VerifiedDeal,
Client :v{{.v}}.Client,
Provider :v{{.v}}.Provider,
Label: label,
StartEpoch : v{{.v}}.StartEpoch,
EndEpoch :v{{.v}}.EndEpoch,
StoragePricePerEpoch :v{{.v}}.StoragePricePerEpoch,
ProviderCollateral :v{{.v}}.ProviderCollateral,
ClientCollateral :v{{.v}}.ClientCollateral,
}, nil
}
type dealProposals{{.v}} struct {

View File

@ -182,8 +182,30 @@ func (s *dealStates0) array() adt.Array {
return s.Array
}
func fromV0DealState(v0 market0.DealState) DealState {
return (DealState)(v0)
func fromV0DealState(v0 market0.DealState) (DealState, error) {
label, err := labelFromGoString(v0.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v0.PieceCID,
PieceSize: v0.PieceSize,
VerifiedDeal: v0.VerifiedDeal,
Client: v0.Client,
Provider: v0.Provider,
Label: label,
StartEpoch: v0.StartEpoch,
EndEpoch: v0.EndEpoch,
StoragePricePerEpoch: v0.StoragePricePerEpoch,
ProviderCollateral: v0.ProviderCollateral,
ClientCollateral: v0.ClientCollateral,
}, nil
}
type dealProposals0 struct {

View File

@ -182,8 +182,30 @@ func (s *dealStates2) array() adt.Array {
return s.Array
}
func fromV2DealState(v2 market2.DealState) DealState {
return (DealState)(v2)
func fromV2DealState(v2 market2.DealState) (DealState, error) {
label, err := labelFromGoString(v2.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v2.PieceCID,
PieceSize: v2.PieceSize,
VerifiedDeal: v2.VerifiedDeal,
Client: v2.Client,
Provider: v2.Provider,
Label: label,
StartEpoch: v2.StartEpoch,
EndEpoch: v2.EndEpoch,
StoragePricePerEpoch: v2.StoragePricePerEpoch,
ProviderCollateral: v2.ProviderCollateral,
ClientCollateral: v2.ClientCollateral,
}, nil
}
type dealProposals2 struct {

View File

@ -177,8 +177,30 @@ func (s *dealStates3) array() adt.Array {
return s.Array
}
func fromV3DealState(v3 market3.DealState) DealState {
return (DealState)(v3)
func fromV3DealState(v3 market3.DealState) (DealState, error) {
label, err := labelFromGoString(v3.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v3.PieceCID,
PieceSize: v3.PieceSize,
VerifiedDeal: v3.VerifiedDeal,
Client: v3.Client,
Provider: v3.Provider,
Label: label,
StartEpoch: v3.StartEpoch,
EndEpoch: v3.EndEpoch,
StoragePricePerEpoch: v3.StoragePricePerEpoch,
ProviderCollateral: v3.ProviderCollateral,
ClientCollateral: v3.ClientCollateral,
}, nil
}
type dealProposals3 struct {

View File

@ -177,8 +177,30 @@ func (s *dealStates4) array() adt.Array {
return s.Array
}
func fromV4DealState(v4 market4.DealState) DealState {
return (DealState)(v4)
func fromV4DealState(v4 market4.DealState) (DealState, error) {
label, err := labelFromGoString(v4.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v4.PieceCID,
PieceSize: v4.PieceSize,
VerifiedDeal: v4.VerifiedDeal,
Client: v4.Client,
Provider: v4.Provider,
Label: label,
StartEpoch: v4.StartEpoch,
EndEpoch: v4.EndEpoch,
StoragePricePerEpoch: v4.StoragePricePerEpoch,
ProviderCollateral: v4.ProviderCollateral,
ClientCollateral: v4.ClientCollateral,
}, nil
}
type dealProposals4 struct {

View File

@ -177,8 +177,30 @@ func (s *dealStates5) array() adt.Array {
return s.Array
}
func fromV5DealState(v5 market5.DealState) DealState {
return (DealState)(v5)
func fromV5DealState(v5 market5.DealState) (DealState, error) {
label, err := labelFromGoString(v5.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v5.PieceCID,
PieceSize: v5.PieceSize,
VerifiedDeal: v5.VerifiedDeal,
Client: v5.Client,
Provider: v5.Provider,
Label: label,
StartEpoch: v5.StartEpoch,
EndEpoch: v5.EndEpoch,
StoragePricePerEpoch: v5.StoragePricePerEpoch,
ProviderCollateral: v5.ProviderCollateral,
ClientCollateral: v5.ClientCollateral,
}, nil
}
type dealProposals5 struct {

View File

@ -177,8 +177,30 @@ func (s *dealStates6) array() adt.Array {
return s.Array
}
func fromV6DealState(v6 market6.DealState) DealState {
return (DealState)(v6)
func fromV6DealState(v6 market6.DealState) (DealState, error) {
label, err := labelFromGoString(v6.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v6.PieceCID,
PieceSize: v6.PieceSize,
VerifiedDeal: v6.VerifiedDeal,
Client: v6.Client,
Provider: v6.Provider,
Label: label,
StartEpoch: v6.StartEpoch,
EndEpoch: v6.EndEpoch,
StoragePricePerEpoch: v6.StoragePricePerEpoch,
ProviderCollateral: v6.ProviderCollateral,
ClientCollateral: v6.ClientCollateral,
}, nil
}
type dealProposals6 struct {

View File

@ -177,8 +177,30 @@ func (s *dealStates7) array() adt.Array {
return s.Array
}
func fromV7DealState(v7 market7.DealState) DealState {
return (DealState)(v7)
func fromV7DealState(v7 market7.DealState) (DealState, error) {
label, err := labelFromGoString(v7.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v7.PieceCID,
PieceSize: v7.PieceSize,
VerifiedDeal: v7.VerifiedDeal,
Client: v7.Client,
Provider: v7.Provider,
Label: label,
StartEpoch: v7.StartEpoch,
EndEpoch: v7.EndEpoch,
StoragePricePerEpoch: v7.StoragePricePerEpoch,
ProviderCollateral: v7.ProviderCollateral,
ClientCollateral: v7.ClientCollateral,
}, nil
}
type dealProposals7 struct {

View File

@ -177,8 +177,27 @@ func (s *dealStates8) array() adt.Array {
return s.Array
}
func fromV8DealState(v8 market8.DealState) DealState {
return (DealState)(v8)
func fromV8DealState(v8 market8.DealState) (DealState, error) {
label := v8.Label
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,
}, nil
}
type dealProposals8 struct {