Skip to content

Commit

Permalink
fix: log
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Jul 29, 2024
1 parent eb37704 commit 695973c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ jobs:
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:latest
10 changes: 6 additions & 4 deletions core/blockarchiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

bundlesdk "github.com/bnb-chain/greenfield-bundle-sdk/bundle"
)
Expand Down Expand Up @@ -145,23 +146,24 @@ func (c *Client) GetBundleBlocks(ctx context.Context, objectName string) ([]*Blo

tempFile, err := os.CreateTemp("", "bundle")
if err != nil {
fmt.Printf("Failed to create temporary file: %v\n", err)
log.Error("Failed to create temporary file: %v\n", err)
return nil, err
}
defer os.Remove(tempFile.Name())
// Write the content to the temporary file
_, err = tempFile.Write(body)
if err != nil {
fmt.Printf("Failed to write downloaded bundle to file: %v\n", err)
log.Error("Failed to write downloaded bundle to file: %v\n", err)
return nil, err
}
defer tempFile.Close()

bundleObjects, err := bundlesdk.NewBundleFromFile(tempFile.Name())
if err != nil {
fmt.Printf("Failed to create bundle from file: %v\n", err)
log.Error("Failed to create bundle from file: %v\n", err)
return nil, err
}

var blocksInfo []*Block
for _, objMeta := range bundleObjects.GetBundleObjectsMeta() {
objFile, _, err := bundleObjects.GetObject(objMeta.Name)
Expand All @@ -184,7 +186,7 @@ func (c *Client) GetBundleBlocks(ctx context.Context, objectName string) ([]*Blo
}
blocksInfo = append(blocksInfo, blockInfo)
}

log.Info("fetched bundle of blocks", "number", blocksInfo[0].Number)
return blocksInfo, nil
}

Expand Down
4 changes: 2 additions & 2 deletions core/blockarchiver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"math/big"
"strconv"
"strings"
"sync"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/sasha-s/go-deadlock"
)

// JsonError represents an error in JSON format
Expand Down Expand Up @@ -123,7 +123,7 @@ type RequestLock struct {
// if the number is within any of the ranges, but we don't need to populate the lookup every time a new range is added.
rangeMap map[uint64]*Range
lookupMap map[uint64]*Range
mu sync.RWMutex
mu deadlock.RWMutex
}

// NewRequestLock creates a new RequestLock
Expand Down

0 comments on commit 695973c

Please sign in to comment.