From 49df3138a8525d4bfe73adf2eac2fd2458528718 Mon Sep 17 00:00:00 2001 From: LexLuthr <88259624+LexLuthr@users.noreply.github.com> Date: Wed, 31 May 2023 15:57:57 +0400 Subject: [PATCH] feat: Show elapsed epoch and PSD wait epochs in UI (#1480) * show epochs * fix devnet UI, use BlockdDelaySecs * fix lint err * Update gql/resolver.go Co-authored-by: dirkmc --------- Co-authored-by: dirkmc --- docker/devnet/boost/entrypoint.sh | 1 + docker/devnet/docker-compose.yaml | 2 +- gql/resolver.go | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docker/devnet/boost/entrypoint.sh b/docker/devnet/boost/entrypoint.sh index f5bf2454e..82a77e7a6 100755 --- a/docker/devnet/boost/entrypoint.sh +++ b/docker/devnet/boost/entrypoint.sh @@ -40,6 +40,7 @@ if [ ! -f $BOOST_PATH/.init.boost ]; then echo Setting port in boost config... sed -i 's|ip4/0.0.0.0/tcp/0|ip4/0.0.0.0/tcp/50000|g' $BOOST_PATH/config.toml + sed -i 's|127.0.0.1|0.0.0.0|g' $BOOST_PATH/config.toml echo Done touch $BOOST_PATH/.init.boost diff --git a/docker/devnet/docker-compose.yaml b/docker/devnet/docker-compose.yaml index 2e890ff45..ccbb8a823 100644 --- a/docker/devnet/docker-compose.yaml +++ b/docker/devnet/docker-compose.yaml @@ -138,4 +138,4 @@ services: environment: HTTP_BIND: "${HTTP_BIND:-127.0.0.1}" HTTP_PORT: "${HTTP_PORT:-4080}" - network_mode: host \ No newline at end of file + network_mode: host diff --git a/gql/resolver.go b/gql/resolver.go index 7195d42e3..26a9f8d7f 100644 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "math" + "time" "github.com/dustin/go-humanize" "github.com/filecoin-project/boost-gfm/piecestore" @@ -26,6 +27,7 @@ import ( "github.com/filecoin-project/boost/transport" "github.com/filecoin-project/dagstore" "github.com/filecoin-project/lotus/api/v1api" + "github.com/filecoin-project/lotus/build" lotus_repo "github.com/filecoin-project/lotus/node/repo" "github.com/google/uuid" "github.com/graph-gophers/graphql-go" @@ -527,14 +529,14 @@ func (dr *dealResolver) Retry() string { } func (dr *dealResolver) Message(ctx context.Context) string { - msg := dr.message(ctx, dr.ProviderDealState.Checkpoint) + msg := dr.message(ctx, dr.ProviderDealState.Checkpoint, dr.ProviderDealState.CheckpointAt) if dr.ProviderDealState.Retry != types.DealRetryFatal && dr.ProviderDealState.Err != "" { msg = "Paused at '" + msg + "': " + dr.ProviderDealState.Err } return msg } -func (dr *dealResolver) message(ctx context.Context, checkpoint dealcheckpoints.Checkpoint) string { +func (dr *dealResolver) message(ctx context.Context, checkpoint dealcheckpoints.Checkpoint, checkpointAt time.Time) string { switch checkpoint { case dealcheckpoints.Accepted: if dr.IsOffline { @@ -570,7 +572,9 @@ func (dr *dealResolver) message(ctx context.Context, checkpoint dealcheckpoints. case dealcheckpoints.Transferred: return "Ready to Publish" case dealcheckpoints.Published: - return "Awaiting Publish Confirmation" + elapsedEpochs := uint64(time.Since(checkpointAt).Seconds()) / build.BlockDelaySecs + confidenceEpochs := build.MessageConfidence * 2 + return fmt.Sprintf("Awaiting Publish Confirmation (%d/%d epochs)", elapsedEpochs, confidenceEpochs) case dealcheckpoints.PublishConfirmed: return "Adding to Sector" case dealcheckpoints.AddedPiece: