Skip to content

Commit

Permalink
Merge pull request #1229 from 0chain/fix/update-gosdk
Browse files Browse the repository at this point in the history
Update gosdk
  • Loading branch information
Kishan-Dhakan authored Sep 1, 2023
2 parents 60317da + 95dba05 commit 9c40d91
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 24 deletions.
1 change: 0 additions & 1 deletion code/go/0chain.net/blobber/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func reloadConfig() error {

config.Configuration.Capacity = viper.GetInt64("capacity")

config.Configuration.MinLockDemand = viper.GetFloat64("min_lock_demand")
config.Configuration.NumDelegates = viper.GetInt("num_delegates")
config.Configuration.ReadPrice = viper.GetFloat64("read_price")
config.Configuration.ServiceCharge = viper.GetFloat64("service_charge")
Expand Down
7 changes: 3 additions & 4 deletions code/go/0chain.net/blobbercore/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ type Config struct {

HealthCheckWorkerFreq time.Duration

ReadPrice float64
WritePrice float64
PriceInUSD bool
MinLockDemand float64
ReadPrice float64
WritePrice float64
PriceInUSD bool

// WriteMarkerLockTimeout lock is released automatically if it is timeout
WriteMarkerLockTimeout time.Duration
Expand Down
8 changes: 2 additions & 6 deletions code/go/0chain.net/blobbercore/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const TableNameSettings = "settings"
type Settings struct {
ID string `gorm:"column:id;size:10;primaryKey"`
Capacity int64 `gorm:"column:capacity;not null;default:0"`
MinLockDemand float64 `gorm:"column:min_lock_demand;not null;default:0"`
NumDelegates int `gorm:"column:num_delegates;not null;default:100"`
ReadPrice float64 `gorm:"column:read_price;not null;default:0"`
WritePrice float64 `gorm:"column:write_price;not null;default:0"`
Expand All @@ -40,7 +39,6 @@ func (s *Settings) CopyTo(c *Config) error {

c.Capacity = s.Capacity

c.MinLockDemand = s.MinLockDemand
c.NumDelegates = s.NumDelegates
c.ReadPrice = s.ReadPrice
c.ServiceCharge = s.ServiceCharge
Expand All @@ -56,7 +54,6 @@ func (s *Settings) CopyFrom(c *Config) error {
}

s.Capacity = c.Capacity
s.MinLockDemand = c.MinLockDemand
s.NumDelegates = c.NumDelegates
s.ReadPrice = c.ReadPrice
s.ServiceCharge = c.ServiceCharge
Expand Down Expand Up @@ -118,8 +115,7 @@ func ReloadFromChain(ctx context.Context, db *gorm.DB) (*zcncore.Blobber, error)
}

Configuration.Capacity = int64(b.Capacity)
Configuration.MinLockDemand = b.Terms.MinLockDemand
Configuration.NumDelegates = b.StakePoolSettings.NumDelegates
Configuration.NumDelegates = *b.StakePoolSettings.NumDelegates

if token, err := b.Terms.ReadPrice.ToToken(); err != nil {
return nil, err
Expand All @@ -133,6 +129,6 @@ func ReloadFromChain(ctx context.Context, db *gorm.DB) (*zcncore.Blobber, error)
Configuration.WritePrice = token
}

Configuration.ServiceCharge = b.StakePoolSettings.ServiceCharge
Configuration.ServiceCharge = *b.StakePoolSettings.ServiceCharge
return b, Update(ctx, db)
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func BenchmarkUploadFileWithDisk(b *testing.B) {
hasher := sdk.CreateHasher(int64(bm.ChunkSize))
isFinal := false

body, formData, _ := formBuilder.Build(fileMeta, hasher, strconv.FormatInt(time.Now().UnixNano(), 10), int64(bm.ChunkSize), 0, 0, isFinal, "", [][]byte{chunkBytes}, nil)
body, formData, _ := formBuilder.Build(fileMeta, hasher, strconv.FormatInt(time.Now().UnixNano(), 10), int64(bm.ChunkSize), 0, 0, isFinal, "", "", [][]byte{chunkBytes}, nil, 0)

req, err := blobber.NewRequest(http.MethodPost, "http://127.0.0.1:5051/v1/file/upload/benchmark_upload", body)

Expand Down Expand Up @@ -160,7 +160,7 @@ func BenchmarkUploadFileWithNoDisk(b *testing.B) {
hasher := sdk.CreateHasher(int64(bm.ChunkSize))
isFinal := false

body, formData, _ := formBuilder.Build(fileMeta, hasher, strconv.FormatInt(time.Now().UnixNano(), 10), int64(bm.ChunkSize), 0, 0, isFinal, "", [][]byte{chunkBytes}, nil)
body, formData, _ := formBuilder.Build(fileMeta, hasher, strconv.FormatInt(time.Now().UnixNano(), 10), int64(bm.ChunkSize), 0, 0, isFinal, "", "", [][]byte{chunkBytes}, nil, 0)

req, err := blobber.NewRequest(http.MethodPost, "http://127.0.0.1:5051/v1/file/upload/benchmark_upload", body)

Expand Down
1 change: 0 additions & 1 deletion code/go/0chain.net/blobbercore/handler/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func getStorageNode() (*transaction.StorageNode, error) {
}
sn.Terms.ReadPrice = zcncore.ConvertToValue(readPrice)
sn.Terms.WritePrice = zcncore.ConvertToValue(writePrice)
sn.Terms.MinLockDemand = config.Configuration.MinLockDemand

sn.StakePoolSettings.DelegateWallet = config.Configuration.DelegateWallet
sn.StakePoolSettings.NumDelegates = config.Configuration.NumDelegates
Expand Down
8 changes: 3 additions & 5 deletions code/go/0chain.net/blobbercore/stats/blobberstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ type BlobberStats struct {
AllocationListPagination *Pagination `json:"allocation_list_pagination,omitempty"`

// configurations
Capacity int64 `json:"capacity"`
ReadPrice float64 `json:"read_price"`
WritePrice float64 `json:"write_price"`
MinLockDemand float64 `json:"min_lock_demand"`
Capacity int64 `json:"capacity"`
ReadPrice float64 `json:"read_price"`
WritePrice float64 `json:"write_price"`

AllocationStats []*AllocationStats `json:"-"`

Expand Down Expand Up @@ -106,7 +105,6 @@ func (bs *BlobberStats) loadBasicStats(ctx context.Context) {
bs.Capacity = config.Configuration.Capacity
bs.ReadPrice = config.Configuration.ReadPrice
bs.WritePrice = config.Configuration.WritePrice
bs.MinLockDemand = config.Configuration.MinLockDemand
//
du := filestore.GetFileStore().GetTotalFilesSize()

Expand Down
1 change: 0 additions & 1 deletion code/go/0chain.net/blobbercore/stats/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ const tpl = `
<tr><td>Capacity</td><td>{{ byte_count_in_string .Capacity }}</td></tr>
<tr><td>Read price</td><td>{{ .ReadPrice }}</td></tr>
<tr><td>Write price</td><td>{{ .WritePrice }}</td></tr>
<tr><td>Min lock demand</td><td>{{ .MinLockDemand }}</td></tr>
</table>
</td>
<td valign='top'>
Expand Down
4 changes: 0 additions & 4 deletions code/go/0chain.net/core/transaction/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ type Terms struct {
// WritePrice is price for reading. Token / GB. Also,
// it used to calculate min_lock_demand value.
WritePrice uint64 `json:"write_price"`
// MinLockDemand in number in [0; 1] range. It represents part of
// allocation should be locked for the blobber rewards even if
// user never write something to the blobber.
MinLockDemand float64 `json:"min_lock_demand"`
}

type StakePoolSettings struct {
Expand Down

0 comments on commit 9c40d91

Please sign in to comment.