Skip to content

Commit

Permalink
feat: bs add bucket field (#1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
constwz authored May 23, 2024
1 parent 5519ea7 commit fda8b27
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/aliyun/credentials-go v1.3.0
github.com/avast/retry-go/v4 v4.3.1
github.com/aws/aws-sdk-go v1.44.159
github.com/bnb-chain/greenfield v1.6.0
github.com/bnb-chain/greenfield v1.7.1-0.20240521062200-cc41c389096c
github.com/bnb-chain/greenfield-common/go v0.0.0-20240228080631-2683b0ee669a
github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
github.com/cometbft/cometbft v0.38.6
Expand Down Expand Up @@ -70,7 +70,7 @@ require (
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd v0.23.4 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s=
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo=
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/bnb-chain/greenfield v1.6.0 h1:AAEJjtwED6XVckPRqMSa6nUciEeBNszeJhNiO/2KNiE=
github.com/bnb-chain/greenfield v1.6.0/go.mod h1:KCjy1bsc5q2G4IjyhKX0r3BQM+4rooZ1/fNnGlq8o3I=
github.com/bnb-chain/greenfield v1.7.1-0.20240521062200-cc41c389096c h1:azKKvzAC/yLthneXB1sH6iPwVVj7sRK8X58PuTU/TsM=
github.com/bnb-chain/greenfield v1.7.1-0.20240521062200-cc41c389096c/go.mod h1:RkoY1ISUFUMNbw2iR7iX8M+ToqmB8AlcRFKpwCJEX3Q=
github.com/bnb-chain/greenfield-cometbft v1.2.1-0.20240408033601-a6b682aa870e h1:4ttDy8yBhBUW0gdFyBK0wHMJS5ZtlhBdoYx/O6T6Eqg=
github.com/bnb-chain/greenfield-cometbft v1.2.1-0.20240408033601-a6b682aa870e/go.mod h1:q9/nqW19iXvxyma5XgcZfxL/OkWI9s5e7yX9ecePz8A=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU=
Expand Down
8 changes: 4 additions & 4 deletions modular/blocksyncer/modules/bucket/bucket_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (m *Module) handleEventMigrationBucket(ctx context.Context, block *tmctypes
bucket := &models.Bucket{
BucketID: common.BigToHash(migrationBucket.BucketId.BigInt()),
BucketName: migrationBucket.BucketName,
Status: storagetypes.BUCKET_STATUS_MIGRATING.String(),
Status: migrationBucket.Status.String(),

UpdateAt: block.Block.Height,
UpdateTxHash: txHash,
Expand All @@ -256,7 +256,7 @@ func (m *Module) handleEventCancelMigrationBucket(ctx context.Context, block *tm
bucket := &models.Bucket{
BucketID: common.BigToHash(cancelMigrationBucket.BucketId.BigInt()),
BucketName: cancelMigrationBucket.BucketName,
Status: storagetypes.BUCKET_STATUS_CREATED.String(),
Status: cancelMigrationBucket.Status.String(),

UpdateAt: block.Block.Height,
UpdateTxHash: txHash,
Expand All @@ -273,7 +273,7 @@ func (m *Module) handleEventRejectMigrateBucket(ctx context.Context, block *tmct
bucket := &models.Bucket{
BucketID: common.BigToHash(rejectMigrateBucket.BucketId.BigInt()),
BucketName: rejectMigrateBucket.BucketName,
Status: storagetypes.BUCKET_STATUS_CREATED.String(),
Status: rejectMigrateBucket.Status.String(),

UpdateAt: block.Block.Height,
UpdateTxHash: txHash,
Expand All @@ -291,7 +291,7 @@ func (m *Module) handleCompleteMigrationBucket(ctx context.Context, block *tmcty
BucketID: common.BigToHash(completeMigrationBucket.BucketId.BigInt()),
BucketName: completeMigrationBucket.BucketName,
GlobalVirtualGroupFamilyId: completeMigrationBucket.GlobalVirtualGroupFamilyId,
Status: storagetypes.BUCKET_STATUS_CREATED.String(),
Status: completeMigrationBucket.Status.String(),

UpdateAt: block.Block.Height,
UpdateTxHash: txHash,
Expand Down
5 changes: 4 additions & 1 deletion modular/blocksyncer/modules/events/sp_events_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (m *Module) handleMigrationBucket(ctx context.Context, block *tmctypes.Resu
Operator: common.HexToAddress(migrationBucket.Operator),
BucketName: migrationBucket.BucketName,
DstPrimarySpId: migrationBucket.DstPrimarySpId,
Status: migrationBucket.Status.String(),

CreateAt: block.Block.Height,
CreateTxHash: txHash,
Expand All @@ -155,6 +156,7 @@ func (m *Module) handleCompleteMigrationBucket(ctx context.Context, block *tmcty
BucketName: completeMigrationBucket.BucketName,
GlobalVirtualGroupFamilyId: completeMigrationBucket.GlobalVirtualGroupFamilyId,
SrcPrimarySpId: completeMigrationBucket.SrcPrimarySpId,
Status: completeMigrationBucket.Status.String(),

CreateAt: block.Block.Height,
CreateTxHash: txHash,
Expand Down Expand Up @@ -261,11 +263,11 @@ func (m *Module) handleCompleteStorageProviderExit(ctx context.Context, block *t
}

func (m *Module) handleCancelMigrationBucket(ctx context.Context, block *tmctypes.ResultBlock, txHash common.Hash, cancelMigrationBucket *storagetypes.EventCancelMigrationBucket) map[string][]interface{} {

eventCancelMigrationBucket := &bsdb.EventCancelMigrationBucket{
BucketID: common.BigToHash(cancelMigrationBucket.BucketId.BigInt()),
Operator: common.HexToAddress(cancelMigrationBucket.Operator),
BucketName: cancelMigrationBucket.BucketName,
Status: cancelMigrationBucket.Status.String(),

CreateAt: block.Block.Height,
CreateTxHash: txHash,
Expand All @@ -283,6 +285,7 @@ func (m *Module) handleRejectMigrateBucket(ctx context.Context, block *tmctypes.
BucketID: common.BigToHash(migrationBucket.BucketId.BigInt()),
Operator: common.HexToAddress(migrationBucket.Operator),
BucketName: migrationBucket.BucketName,
Status: migrationBucket.Status.String(),

CreateAt: block.Block.Height,
CreateTxHash: txHash,
Expand Down
1 change: 1 addition & 0 deletions store/bsdb/event_cancel_migration_bucket_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type EventCancelMigrationBucket struct {
BucketID common.Hash `gorm:"column:bucket_id;type:BINARY(32);index:idx_bucket_id"`
Operator common.Address `gorm:"column:operator;type:BINARY(20)"`
BucketName string `gorm:"column:bucket_name;type:varchar(64);index:idx_bucket_name"`
Status string `gorm:"column:status"`

CreateAt int64 `gorm:"column:create_at"`
CreateTxHash common.Hash `gorm:"column:create_tx_hash;type:BINARY(32);not null"`
Expand Down
1 change: 1 addition & 0 deletions store/bsdb/event_complete_migration_bucket_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type EventCompleteMigrationBucket struct {
BucketName string `gorm:"column:bucket_name;type:varchar(64);index:idx_bucket_name"`
GlobalVirtualGroupFamilyId uint32 `gorm:"column:global_virtual_group_family_id"`
SrcPrimarySpId uint32 `gorm:"column:src_primary_sp_id"`
Status string `gorm:"column:status"`

CreateAt int64 `gorm:"column:create_at"`
CreateTxHash common.Hash `gorm:"column:create_tx_hash;type:BINARY(32);not null"`
Expand Down
1 change: 1 addition & 0 deletions store/bsdb/event_migration_bucket_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type EventMigrationBucket struct {
Operator common.Address `gorm:"column:operator;type:BINARY(20)"`
BucketName string `gorm:"column:bucket_name;type:varchar(64);index:idx_bucket_name"`
DstPrimarySpId uint32 `gorm:"column:dst_primary_sp_id"`
Status string `gorm:"column:status"`

CreateAt int64 `gorm:"column:create_at"`
CreateTxHash common.Hash `gorm:"column:create_tx_hash;type:BINARY(32);not null"`
Expand Down
1 change: 1 addition & 0 deletions store/bsdb/event_reject_migrate_bucket_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type EventRejectMigrateBucket struct {
BucketID common.Hash `gorm:"column:bucket_id;type:BINARY(32);index:idx_bucket_id"`
Operator common.Address `gorm:"column:operator;type:BINARY(20)"`
BucketName string `gorm:"column:bucket_name;type:varchar(64);index:idx_bucket_name"`
Status string `gorm:"column:status"`

CreateAt int64 `gorm:"column:create_at"`
CreateTxHash common.Hash `gorm:"column:create_tx_hash;type:BINARY(32);not null"`
Expand Down

0 comments on commit fda8b27

Please sign in to comment.