From f0adf338cd56649fcec92d3bcdade884b8d45bbd Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Wed, 10 Mar 2021 13:25:19 +0100 Subject: [PATCH] add expected duration --- storagemarket/dealstatus.go | 33 ++++++++++++++++++++++++++++++ storagemarket/types.go | 17 +++++++++------- storagemarket/types_cbor_gen.go | 36 ++++++++++++++++++++++++++++++++- 3 files changed, 78 insertions(+), 8 deletions(-) diff --git a/storagemarket/dealstatus.go b/storagemarket/dealstatus.go index 2d3b238c9..8aa0b1fca 100644 --- a/storagemarket/dealstatus.go +++ b/storagemarket/dealstatus.go @@ -175,3 +175,36 @@ var DealStatesDescriptions = map[StorageDealStatus]string{ StorageDealClientTransferRestart: "Client transfer restart", StorageDealProviderTransferAwaitRestart: "ProviderTransferAwaitRestart", } + +var DealStatesDurations = map[StorageDealStatus]string{ + StorageDealUnknown: "", + StorageDealProposalNotFound: "", + StorageDealProposalRejected: "", + StorageDealProposalAccepted: "a few minutes", + StorageDealAcceptWait: "a few minutes", + StorageDealStartDataTransfer: "a few minutes", + StorageDealStaged: "a few minutes", + StorageDealAwaitingPreCommit: "a few minutes", + StorageDealSealing: "a few hours", + StorageDealActive: "", + StorageDealExpired: "", + StorageDealSlashed: "", + StorageDealRejecting: "", + StorageDealFailing: "", + StorageDealFundsReserved: "a few minutes", + StorageDealCheckForAcceptance: "a few minutes", + StorageDealValidating: "a few minutes", + StorageDealTransferring: "a few minutes", + StorageDealWaitingForData: "a few minutes", + StorageDealVerifyData: "a few minutes", + StorageDealReserveProviderFunds: "a few minutes", + StorageDealReserveClientFunds: "a few minutes", + StorageDealProviderFunding: "a few minutes", + StorageDealClientFunding: "a few minutes", + StorageDealPublish: "a few minutes", + StorageDealPublishing: "a few minutes", + StorageDealError: "", + StorageDealFinalizing: "a few minutes", + StorageDealClientTransferRestart: "depending on data size, anywhere between a few minutes to a few hours", + StorageDealProviderTransferAwaitRestart: "a few minutes", +} diff --git a/storagemarket/types.go b/storagemarket/types.go index 7480c0c22..f89117ac9 100644 --- a/storagemarket/types.go +++ b/storagemarket/types.go @@ -137,7 +137,7 @@ func (ds *DealStages) GetStage(stage string) *DealStage { return nil } -func (ds *DealStages) AddStageLog(stage, description, msg string) { +func (ds *DealStages) AddStageLog(stage, description, expectedDuration, msg string) { log.Infof("adding log for stage <%s> msg <%s>", stage, msg) now := curTime() @@ -151,6 +151,7 @@ func (ds *DealStages) AddStageLog(stage, description, msg string) { st.Name = stage st.Description = description + st.ExpectedDuration = expectedDuration st.UpdatedTime = now if msg != "" && (len(st.Logs) == 0 || st.Logs[len(st.Logs)-1].Log != msg) { st.Logs = append(st.Logs, &Log{msg, now}) @@ -158,11 +159,12 @@ func (ds *DealStages) AddStageLog(stage, description, msg string) { } type DealStage struct { - Name string - Description string - CreatedTime cbg.CborTime - UpdatedTime cbg.CborTime - Logs []*Log + Name string + Description string + ExpectedDuration string + CreatedTime cbg.CborTime + UpdatedTime cbg.CborTime + Logs []*Log } func (d *ClientDeal) AddLog(msg string, a ...interface{}) { @@ -172,8 +174,9 @@ func (d *ClientDeal) AddLog(msg string, a ...interface{}) { stage := DealStates[d.State] description := DealStatesDescriptions[d.State] + expectedDuration := DealStatesDurations[d.State] - d.DealStages.AddStageLog(stage, description, msg) + d.DealStages.AddStageLog(stage, description, expectedDuration, msg) } // ClientDeal is the local state tracked for a deal by a StorageClient diff --git a/storagemarket/types_cbor_gen.go b/storagemarket/types_cbor_gen.go index 924f09e6d..c9b7b29bf 100644 --- a/storagemarket/types_cbor_gen.go +++ b/storagemarket/types_cbor_gen.go @@ -2766,7 +2766,7 @@ func (t *DealStage) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{165}); err != nil { + if _, err := w.Write([]byte{166}); err != nil { return err } @@ -2818,6 +2818,29 @@ func (t *DealStage) MarshalCBOR(w io.Writer) error { return err } + // t.ExpectedDuration (string) (string) + if len("ExpectedDuration") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"ExpectedDuration\" was too long") + } + + if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("ExpectedDuration"))); err != nil { + return err + } + if _, err := io.WriteString(w, string("ExpectedDuration")); err != nil { + return err + } + + if len(t.ExpectedDuration) > cbg.MaxLength { + return xerrors.Errorf("Value in field t.ExpectedDuration was too long") + } + + if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len(t.ExpectedDuration))); err != nil { + return err + } + if _, err := io.WriteString(w, string(t.ExpectedDuration)); err != nil { + return err + } + // t.CreatedTime (typegen.CborTime) (struct) if len("CreatedTime") > cbg.MaxLength { return xerrors.Errorf("Value in field \"CreatedTime\" was too long") @@ -2932,6 +2955,17 @@ func (t *DealStage) UnmarshalCBOR(r io.Reader) error { t.Description = string(sval) } + // t.ExpectedDuration (string) (string) + case "ExpectedDuration": + + { + sval, err := cbg.ReadStringBuf(br, scratch) + if err != nil { + return err + } + + t.ExpectedDuration = string(sval) + } // t.CreatedTime (typegen.CborTime) (struct) case "CreatedTime":