Skip to content

Commit

Permalink
add expected duration
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Mar 10, 2021
1 parent f50cb2d commit f0adf33
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 8 deletions.
33 changes: 33 additions & 0 deletions storagemarket/dealstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
17 changes: 10 additions & 7 deletions storagemarket/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -151,18 +151,20 @@ 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})
}
}

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{}) {
Expand All @@ -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
Expand Down
36 changes: 35 additions & 1 deletion storagemarket/types_cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0adf33

Please sign in to comment.