Skip to content

Commit f8e8ae2

Browse files
authored
Merge branch 'sprint-1.16' into feat/ref-index
2 parents 6e4a0f5 + 88e40a4 commit f8e8ae2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7636
-391
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
- name: Build Base
3636
run: ./docker.local/bin/build.base.sh
3737

38-
- name: Check swagger generation
39-
run: docker.local/bin/test.swagger.sh
40-
4138
- name: Golangci-lint
4239
uses: golangci/golangci-lint-action@v3
4340
with:

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,10 @@ else
188188
sed -i "s/BUF_VERSION := [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/BUF_VERSION := $(VERSION)/g" Makefile
189189
endif
190190
endif
191+
192+
.PHONY: markdown-docs
193+
markdown-docs:
194+
swagger generate spec -o ./swagger.yaml -w ./code/go/0chain.net -m
195+
sed -i '' "s/in\:\ form/in\:\ formData/g" ./swagger.yaml
196+
yq -i '(.paths.*.*.parameters.[] | select(.in == "formData") | select(.type == "object")).type = "file"' swagger.yaml
197+
swagger generate markdown -f ./swagger.yaml --output=swagger.md

code/go/0chain.net/blobber/main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"github.com/0chain/blobber/code/go/0chain.net/core/common"
45
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
56
"github.com/0chain/blobber/code/go/0chain.net/core/node"
67
)
@@ -43,10 +44,14 @@ func main() {
4344
// when enabled "// +build integration_tests", this sets blobber for conductor tests.
4445
prepareBlobber(node.Self.ID)
4546

46-
if err := registerOnChain(); err != nil {
47-
logging.Logger.Error("Error register on blockchain" + err.Error())
48-
panic(err)
49-
}
47+
go func() {
48+
if err := registerOnChain(); err != nil {
49+
logging.Logger.Error("Error register on blockchain" + err.Error())
50+
panic(err)
51+
}
52+
53+
common.SetBlobberRegistered(true)
54+
}()
5055

5156
if err := setStorageScConfigFromChain(); err != nil {
5257
logging.Logger.Error("Error setStorageScConfigFromChain" + err.Error())

code/go/0chain.net/blobber/zcn.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ package main
22

33
import (
44
"fmt"
5-
"time"
6-
75
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/config"
86
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/filestore"
97
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/handler"
108
"github.com/0chain/blobber/code/go/0chain.net/core/chain"
119
"github.com/0chain/blobber/code/go/0chain.net/core/common"
1210
handleCommon "github.com/0chain/blobber/code/go/0chain.net/core/common/handler"
11+
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
1312
"github.com/0chain/blobber/code/go/0chain.net/core/node"
1413
"github.com/0chain/gosdk/zboxcore/sdk"
1514
"github.com/0chain/gosdk/zcncore"
15+
"go.uber.org/zap"
16+
"time"
1617
)
1718

1819
func registerOnChain() error {
@@ -31,8 +32,9 @@ func registerOnChain() error {
3132
return err
3233
}
3334

34-
// setup blobber (add or update) on the blockchain (multiple attempts)
35-
for i := 1; i <= 10; i++ {
35+
// setup blobber (add) on the blockchain (multiple attempts)
36+
i := 1
37+
for {
3638
if i == 1 {
3739
fmt.Printf("\r + connect to sharders:")
3840
} else {
@@ -50,6 +52,9 @@ func registerOnChain() error {
5052
err = handler.RegisterBlobber(common.GetRootContext())
5153
if err == nil {
5254
break
55+
} else {
56+
i++
57+
logging.Logger.Error("add_blobber_error", zap.Error(err))
5358
}
5459
}
5560

code/go/0chain.net/blobbercore/allocation/entity.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
CanRenameMask = uint16(32) // 0010 0000
3939
)
4040

41+
// swagger:model Allocation
4142
type Allocation struct {
4243
ID string `gorm:"column:id;size:64;primaryKey"`
4344
Tx string `gorm:"column:tx;size:64;not null;unique;index:idx_unique_allocations_tx,unique"`
@@ -239,6 +240,7 @@ const (
239240
)
240241

241242
// Terms for allocation by its Tx.
243+
// swagger:model
242244
type Terms struct {
243245
ID int64 `gorm:"column:id;primaryKey"`
244246
BlobberID string `gorm:"blobber_id;size:64;not null"`

code/go/0chain.net/blobbercore/allocation/file_changer_base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/0chain/blobber/code/go/0chain.net/core/encryption"
1212
)
1313

14+
// swagger:model BaseFileChanger
1415
// BaseFileChanger base file change processor
1516
type BaseFileChanger struct {
1617
//client side: unmarshal them from 'updateMeta'/'uploadMeta'

code/go/0chain.net/blobbercore/allocation/file_changer_upload.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/0chain/blobber/code/go/0chain.net/core/common"
1717
)
1818

19+
// swagger:model UploadFileChanger
1920
// UploadFileChanger file change processor for continuous upload in INIT/APPEND/FINALIZE
2021
type UploadFileChanger struct {
2122
BaseFileChanger

code/go/0chain.net/blobbercore/blobberhttp/response.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type ListResult struct {
5555
Entities []map[string]interface{} `json:"list"`
5656
}
5757

58+
// swagger:model DownloadResponse
5859
type DownloadResponse struct {
5960
Success bool `json:"success"`
6061
Data []byte `json:"data"`
@@ -63,6 +64,7 @@ type DownloadResponse struct {
6364
LatestRM *readmarker.ReadMarker `json:"latest_rm"`
6465
}
6566

67+
// swagger:model LatestWriteMarkerResult
6668
type LatestWriteMarkerResult struct {
6769
LatestWM *writemarker.WriteMarker `json:"latest_write_marker"`
6870
PrevWM *writemarker.WriteMarker `json:"prev_write_marker"`

code/go/0chain.net/blobbercore/challenge/timing.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"gorm.io/gorm/clause"
1313
)
1414

15+
// swagger:model ChallengeTiming
1516
type ChallengeTiming struct {
1617
// ChallengeID is the challenge ID generated on blockchain.
1718
ChallengeID string `gorm:"column:challenge_id;size:64;primaryKey" json:"id"`

code/go/0chain.net/blobbercore/filestore/store.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func GetFileStore() FileStorer {
9090
return fileStore
9191
}
9292

93+
// swagger:model FileDownloadResponse
9394
type FileDownloadResponse struct {
9495
Nodes [][][]byte
9596
Indexes [][]int

0 commit comments

Comments
 (0)