Skip to content

Commit 569eb4d

Browse files
authored
Merge pull request #1455 from 0chain/feat/object-limit
Add endpoint for object limit
2 parents e931d04 + 78b777c commit 569eb4d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func deleteFromFileStore(ctx context.Context, allocationID string) error {
401401
return datastore.GetStore().WithNewTransaction(func(ctx context.Context) error {
402402
db := datastore.GetStore().GetTransaction(ctx)
403403

404-
err := db.Model(&reference.Ref{}).Unscoped().Select("id", "validation_root", "thumbnail_hash").
404+
err := db.Model(&reference.Ref{}).Unscoped().Select("id", "validation_root", "thumbnail_hash", "filestore_version").
405405
Where("allocation_id=? AND is_precommit=? AND type=? AND deleted_at is not NULL", allocationID, true, reference.FILE).
406406
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
407407

code/go/0chain.net/blobbercore/handler/handler.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func setupHandlers(s *mux.Router) {
224224
s.HandleFunc("/_config", common.AuthenticateAdmin(common.ToJSONResponse(GetConfig)))
225225
// s.HandleFunc("/_config", RateLimitByCommmitRL(common.ToJSONResponse(GetConfig)))
226226
// s.HandleFunc("/_stats", common.AuthenticateAdmin(StatsHandler)))
227-
s.HandleFunc("/_stats", RateLimitByCommmitRL(StatsHandler))
227+
s.HandleFunc("/objectlimit", RateLimitByCommmitRL(common.ToJSONResponse(GetObjectLimit)))
228228

229229
s.HandleFunc("/_logs", RateLimitByCommmitRL(common.ToJSONResponse(GetLogs)))
230230

@@ -1634,6 +1634,16 @@ func GetConfig(ctx context.Context, r *http.Request) (interface{}, error) {
16341634
return config.Configuration, nil
16351635
}
16361636

1637+
func GetObjectLimit(ctx context.Context, r *http.Request) (interface{}, error) {
1638+
var objLimit struct {
1639+
MaxAllocationDirFiles int
1640+
MaxObjectsInDir int
1641+
}
1642+
objLimit.MaxAllocationDirFiles = config.Configuration.MaxAllocationDirFiles
1643+
objLimit.MaxObjectsInDir = config.Configuration.MaxObjectsInDir
1644+
return objLimit, nil
1645+
}
1646+
16371647
func GetLogs(ctx context.Context, r *http.Request) (interface{}, error) {
16381648
return transaction.Last50Transactions, nil
16391649
}

0 commit comments

Comments
 (0)