From 18318edcaa062eaed6ba58170995abb8c0422cfe Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Tue, 6 Aug 2024 20:46:51 +0800 Subject: [PATCH] fix: fix the get object status from bundle service as it latency too high --- external/cmn/types.go | 3 ++- syncer/verifier.go | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/external/cmn/types.go b/external/cmn/types.go index 011fc16..2ff9c82 100644 --- a/external/cmn/types.go +++ b/external/cmn/types.go @@ -19,7 +19,8 @@ type QuotaInfo struct { } type ObjectInfo struct { - Checksums []string `json:"checksums"` + Checksums []string `json:"checksums"` + ObjectStatus string `json:"object_status"` } type GetObjectInfoResponse struct { diff --git a/syncer/verifier.go b/syncer/verifier.go index 5262d0f..3b016b5 100644 --- a/syncer/verifier.go +++ b/syncer/verifier.go @@ -64,7 +64,6 @@ func (s *BlobSyncer) verify() error { if err != nil { return err } - verifyBlockID := verifyBlock.Slot // validate the bundle info at the start slot of a bundle if verifyBlockID == bundleStartBlockID || !s.DetailedIntegrityCheckEnabled() { @@ -92,13 +91,25 @@ func (s *BlobSyncer) verify() error { } return nil } + // the bundle is not sealed yet if bundleInfo.Status == BundleStatusFinalized || bundleInfo.Status == BundleStatusCreatedOnChain { - if bundle.CreatedTime > 0 && time.Now().Unix()-bundle.CreatedTime > s.config.GetReUploadBundleThresh() { - logging.Logger.Infof("the bundle %s is not sealed and exceed the re-upload threshold %d ", bundleName, s.config.GetReUploadBundleThresh()) - return s.reUploadBundle(bundleName) + // get the object meta from chain + objectMeta, err := s.chainClient.GetObjectMeta(context.Background(), s.getBucketName(), bundleName) + if err != nil { + logging.Logger.Errorf("failed to get object meta from chain, bundleName=%s", bundleName) + return err + } + // check the object info from chain to make sure it is not be sealed + // if it is not be sealed, re-upload it + if objectMeta.ObjectStatus != "OBJECT_STATUS_SEALED" { + if bundle.CreatedTime > 0 && time.Now().Unix()-bundle.CreatedTime > s.config.GetReUploadBundleThresh() { + logging.Logger.Infof("the bundle %s is not sealed and exceed the re-upload threshold %d ", bundleName, s.config.GetReUploadBundleThresh()) + return s.reUploadBundle(bundleName) + } + logging.Logger.Info("the bundle is not sealed yet, bundleName=%s, status = %d", bundleName, bundleInfo.Status) + return nil } - return nil } }