Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ jobs:
- name: Test
run: make test

lint:
runs-on: ubuntu-20.04
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
- uses: actions/checkout@v2
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.38.0
golangci-lint --version
- name: Lint
run: make lint


generated-files-integrity:
runs-on: ubuntu-20.04
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,4 @@ func (a *AllocationChangeCollector) DeleteChanges(ctx context.Context) {
logging.Logger.Error("AllocationChangeProcessor_DeleteTempFile", zap.Error(err))
}
}
return
}
4 changes: 3 additions & 1 deletion code/go/0chain.net/blobbercore/handler/grpcMiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func unaryDatabaseTransactionInjector() grpc.UnaryServerInterceptor {
func unaryTimeoutInterceptor() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
deadline := time.Now().Add(time.Duration(TIMEOUT_SECONDS * time.Second))
ctx, _ = context.WithDeadline(ctx, deadline)
ctx, canceler := context.WithDeadline(ctx, deadline)
defer canceler()

return handler(ctx, req)
}
}
Expand Down
15 changes: 9 additions & 6 deletions code/go/0chain.net/blobbercore/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
package handler

import (
"0chain.net/blobbercore/config"
"0chain.net/blobbercore/constants"
"0chain.net/blobbercore/datastore"
"0chain.net/blobbercore/stats"
"0chain.net/core/common"
"context"
"net/http"
"os"
"runtime/pprof"
"time"

"0chain.net/blobbercore/config"
"0chain.net/blobbercore/constants"
"0chain.net/blobbercore/datastore"
"0chain.net/blobbercore/stats"
"0chain.net/core/common"

. "0chain.net/core/logging"
"go.uber.org/zap"

Expand Down Expand Up @@ -204,7 +205,9 @@ func CommitHandler(ctx context.Context, r *http.Request) (interface{}, error) {
}

func ReferencePathHandler(ctx context.Context, r *http.Request) (interface{}, error) {
ctx, _ = context.WithTimeout(ctx, time.Second*10)
ctx, canceler := context.WithTimeout(ctx, time.Second*10)
defer canceler()

ctx = setupHandlerContext(ctx, r)

response, err := storageHandler.GetReferencePath(ctx, r)
Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/blobbercore/handler/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func RegisterGRPCServices(r *mux.Router, server *grpc.Server) {
blobberService := newGRPCBlobberService(&storageHandler, packHandler)
mux := runtime.NewServeMux()
blobbergrpc.RegisterBlobberServer(server, blobberService)
blobbergrpc.RegisterBlobberHandlerServer(context.Background(), mux, blobberService)
_ = blobbergrpc.RegisterBlobberHandlerServer(context.Background(), mux, blobberService)
r.PathPrefix("/").Handler(mux)
}

Expand Down
6 changes: 3 additions & 3 deletions code/go/0chain.net/blobbercore/handler/storage_handler.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package handler

import (
"0chain.net/core/encryption"
"context"
"encoding/json"
"github.com/gorilla/mux"
"net/http"
"strconv"
"strings"

"0chain.net/core/encryption"
"github.com/gorilla/mux"

"0chain.net/blobbercore/stats"
"go.uber.org/zap"

Expand Down Expand Up @@ -537,7 +538,6 @@ func (fsh *StorageHandler) getReferencePath(ctx context.Context, r *http.Request
}

resCh <- &refPathResult
return
}

func (fsh *StorageHandler) GetObjectPath(ctx context.Context, r *http.Request) (*ObjectPathResult, error) {
Expand Down
5 changes: 2 additions & 3 deletions code/go/0chain.net/blobbercore/util/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package util

import (
"fmt"
"strings"
"reflect"
"errors"
"strings"
)

// Validate unmarshalled data with tag-based rules
Expand All @@ -20,7 +19,7 @@ func UnmarshalValidation(v interface{}) error {
if strings.Contains(validation, "required") && fields.Field(i).IsZero() {
// todo: better try this first:
// jsonFieldName := fields.Type().Field(i).Tag.Get("json")
return errors.New(fmt.Sprintf("The '%s' field is required", fields.Type().Field(i).Name))
return fmt.Errorf("The '%s' field is required", fields.Type().Field(i).Name)
}
}

Expand Down