Skip to content

Commit

Permalink
fix: fix log
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Dec 5, 2023
1 parent aed04d7 commit 6e85f51
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion base/gfspapp/app_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const (
SignerFailureDeposit = "signer_Deposit_failure"

SignerSuccessDeleteGlobalVirtualGroup = "signer_delete_global_virtual_group_success"
SignerFailureDeleteGlobalVirtualGroup = "signer_DeleteGlobalVirtualGroup_failure"
SignerFailureDeleteGlobalVirtualGroup = "signer_delete_global_virtual_group_failure"

UploaderSuccessPutObject = "uploader_put_object_success"
UploaderFailurePutObject = "uploader_put_object_failure"
Expand Down
4 changes: 2 additions & 2 deletions base/gfspapp/sign_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (g *GfSpBaseApp) GfSpSign(ctx context.Context, req *gfspserver.GfSpSignRequ
case *gfspserver.GfSpSignRequest_Deposit:
txHash, err = g.signer.Deposit(ctx, t.Deposit)
if err != nil {
log.CtxErrorw(ctx, "failed to sign deposit", "error", err)
log.CtxErrorw(ctx, "failed to deposit", "error", err)
metrics.ReqCounter.WithLabelValues(SignerFailureDeposit).Inc()
metrics.ReqTime.WithLabelValues(SignerFailureDeposit).Observe(time.Since(startTime).Seconds())
} else {
Expand All @@ -304,7 +304,7 @@ func (g *GfSpBaseApp) GfSpSign(ctx context.Context, req *gfspserver.GfSpSignRequ
case *gfspserver.GfSpSignRequest_DeleteGlobalVirtualGroup:
txHash, err = g.signer.DeleteGlobalVirtualGroup(ctx, t.DeleteGlobalVirtualGroup)
if err != nil {
log.CtxErrorw(ctx, "failed to sign delete global virtual group", "error", err)
log.CtxErrorw(ctx, "failed to delete global virtual group", "error", err)
metrics.ReqCounter.WithLabelValues(SignerFailureDeleteGlobalVirtualGroup).Inc()
metrics.ReqTime.WithLabelValues(SignerFailureDeleteGlobalVirtualGroup).Observe(time.Since(startTime).Seconds())
} else {
Expand Down
24 changes: 14 additions & 10 deletions base/gfspvgmgr/virtual_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func (vgm *virtualGroupManager) monitorGVGUsage(gvg *virtualgrouptypes.GlobalVir

curTime := time.Now().Unix()
if isEmpty(gvg) {
// Remove any GVG from the gvgGCMap if the stored size is no longer empty.
// Remove any GVG from the gvgGCMap if it is no longer empty.
vgm.gvgGCMap.Range(func(k, v interface{}) bool {
safeDeleteTime := v.(int64)
if curTime > safeDeleteTime+int64(time.Minute.Seconds()) {
Expand All @@ -566,12 +566,14 @@ func (vgm *virtualGroupManager) monitorGVGUsage(gvg *virtualgrouptypes.GlobalVir
})

if !byChain {
gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvg.Id)
gvgID := gvg.Id
gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvgID)
if err != nil {
log.Errorw("failed to query global virtual group", "error", err)
log.Errorw("failed to query global virtual group", "gvg_id", gvgID, "error", err)
return
}
if !isEmpty(gvg) {
log.Warnw("the gvg is not empty by querying from chain ", "gvg", gvg)
return
}
}
Expand All @@ -584,8 +586,8 @@ func (vgm *virtualGroupManager) monitorGVGUsage(gvg *virtualgrouptypes.GlobalVir
return
}
safeDeleteTime = val.(int64)
log.Infow("GVG will be deleted at", "safe_delete_time", safeDeleteTime)
if curTime < safeDeleteTime {
log.Infow("GVG will be deleted at", "safe_delete_time", safeDeleteTime)
return
}
log.Infow("start to delete GVG", "GVG", gvg)
Expand All @@ -594,11 +596,11 @@ func (vgm *virtualGroupManager) monitorGVGUsage(gvg *virtualgrouptypes.GlobalVir
GlobalVirtualGroupId: gvg.Id,
})
if err != nil {
log.Errorw("failed to delete global virtual group", "gvgID", gvg.Id, "tx_hash", deleteGVGHash, "error", err)
log.Errorw("failed to delete global virtual group", "gvg_id", gvg.Id, "tx_hash", deleteGVGHash, "error", err)
return
}
vgm.gvgGCMap.Delete(gvg.Id)
log.Infow("GVG is deleted onchain", "GVG", gvg, "tx_hash", deleteGVGHash)
log.Infow("successfully delete GVG", "GVG", gvg, "tx_hash", deleteGVGHash)
deleted = true
return
}
Expand All @@ -615,23 +617,25 @@ func (vgm *virtualGroupManager) monitorGVGUsage(gvg *virtualgrouptypes.GlobalVir
},
}
if !byChain {
gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvg.Id)
gvgID := gvg.Id
gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvgID)
if err != nil {
log.Errorw("failed to query global virtual group", "error", err)
log.Errorw("failed to query global virtual group", "gvg_id", gvgID, "error", err)
return
}
if !needDeposit(gvg, vgParams) {
log.Warnw("the gvg does not need deposit by querying from chain", gvg, gvg)
return
}
}
log.Infow("found GVG need to deposit", "GVG", gvg)
var depositTxHash string
depositTxHash, err = vgm.gfspClient.Deposit(context.Background(), msgDeposit)
if err != nil {
log.Errorw("failed to deposit global virtual group", "gvgID", gvg.Id, "txHash", depositTxHash, "error", err)
log.Errorw("failed to deposit global virtual group", "gvg_id", gvg.Id, "tx_hash", depositTxHash, "error", err)
return
}
log.Infow("GVG is deposited", "GVG", gvg, "depositTxHash", depositTxHash)
log.Infow("successfully deposit GVG", "GVG", gvg, "tx_hash", depositTxHash)
deposited = true
return
}
Expand Down

0 comments on commit 6e85f51

Please sign in to comment.