Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update limit #14

Merged
merged 3 commits into from
Dec 9, 2024
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
17 changes: 16 additions & 1 deletion code/go/0chain.net/blobbercore/allocation/newdirchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/util"
"github.com/0chain/blobber/code/go/0chain.net/core/common"
"github.com/0chain/blobber/code/go/0chain.net/core/encryption"
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
"go.uber.org/zap"
"gorm.io/gorm"
)

Expand All @@ -33,6 +35,19 @@ func (nf *NewDir) ApplyChange(ctx context.Context,
if parentRef == nil || parentRef.ID == 0 {
_, err = reference.Mkdir(ctx, nf.AllocationID, nf.Path, allocationVersion, ts, collector)
} else {
collector.LockTransaction()
defer collector.UnlockTransaction()
dirLookupHash := reference.GetReferenceLookup(nf.AllocationID, nf.Path)
dRef, err := reference.GetLimitedRefFieldsByLookupHash(ctx, nf.AllocationID, dirLookupHash, []string{"id"})
if err != nil && err != gorm.ErrRecordNotFound {
logging.Logger.Error("ApplyChange:Newdir", zap.Error(err))
return err
}
err = nil
// already exists
if dRef != nil && dRef.ID != 0 {
return nil
}
parentIDRef := &parentRef.ID
newRef := reference.NewDirectoryRef()
newRef.AllocationID = nf.AllocationID
Expand All @@ -43,7 +58,7 @@ func (nf *NewDir) ApplyChange(ctx context.Context,
newRef.Name = filepath.Base(nf.Path)
newRef.PathLevel = len(strings.Split(strings.TrimRight(nf.Path, "/"), "/"))
newRef.ParentID = parentIDRef
newRef.LookupHash = reference.GetReferenceLookup(nf.AllocationID, nf.Path)
newRef.LookupHash = dirLookupHash
newRef.CreatedAt = ts
newRef.UpdatedAt = ts
newRef.FileMetaHash = encryption.FastHash(newRef.GetFileMetaHashData())
Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/blobbercore/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func SetupDefaultConfig() {
viper.SetDefault("rate_limiters.block_limit_request", 500)
viper.SetDefault("rate_limiters.block_limit_monthly", 31250000)
viper.SetDefault("rate_limiters.upload_limit_monthly", 31250000)
viper.SetDefault("rate_limiters.commit_limit_monthly", 30000)
viper.SetDefault("rate_limiters.commit_limit_monthly", 1000000000)
viper.SetDefault("rate_limiters.commit_limit_daily", 1600)
viper.SetDefault("rate_limiters.commit_zero_limit_daily", 400)
viper.SetDefault("rate_limiters.max_connection_changes", 100)
Expand Down
1 change: 1 addition & 0 deletions code/go/0chain.net/blobbercore/reference/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func Mkdir(ctx context.Context, allocationID, destpath string, allocationVersion
newRef.AllocationVersion = allocationVersion
err = db.Create(newRef).Error
if err != nil {
logging.Logger.Error("mkdir: failed to create directory", zap.Error(err), zap.String("path", fields[i]))
return nil, err
}
collector.AddToCache(newRef)
Expand Down
2 changes: 1 addition & 1 deletion config/0chain_blobber.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ rate_limiters:
# Max upload limit in a month for a client. Default is 2000GB(the value needs to be in blocks which is data/64KB)
upload_limit_monthly: 31250000
# Max commit limit in a month for a client. Default is 30000
commit_limit_monthly: 30000
commit_limit_monthly: 1000000000
# Max commit limit in a day for a client. Default is 1600
commit_limit_daily: 1600
# Max commit limit with size zero or less in a day for a client. Default is 400
Expand Down
Loading