Skip to content
Closed
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
28 changes: 14 additions & 14 deletions action/protocol/mock_protocol.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion action/protocol/staking/contractstake_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/iotexproject/iotex-address/address"
"github.com/iotexproject/iotex-core/v2/action"
"github.com/iotexproject/iotex-core/v2/action/protocol"
"github.com/iotexproject/iotex-core/v2/action/protocol/staking/contractstaking"
)

var (
Expand All @@ -25,7 +27,18 @@ var (
)

type (

// EventHandler is the interface for handling staking events
EventHandler interface {
PutBucketType(address.Address, *ContractStakingBucketType) error
DeductBucket(address.Address, uint64) (*contractstaking.Bucket, error)
PutBucket(address.Address, uint64, *contractstaking.Bucket) error
DeleteBucket(address.Address, uint64) error
}
// EventProcessor is the interface for processing staking events
EventProcessor interface {
// ProcessReceipts processes receipts
ProcessReceipts(context.Context, ...*action.Receipt) error
}
// ContractStakingIndexer defines the interface of contract staking reader
ContractStakingIndexer interface {
Height() (uint64, error)
Expand All @@ -41,6 +54,8 @@ type (
ContractAddress() address.Address
// LoadStakeView loads the contract stake view from state reader
LoadStakeView(context.Context, protocol.StateReader) (ContractStakeView, error)
// CreateEventProcessor creates a new event processor
CreateEventProcessor(context.Context, EventHandler) EventProcessor
}
// ContractStakingIndexerWithBucketType defines the interface of contract staking reader with bucket type
ContractStakingIndexerWithBucketType interface {
Expand Down
154 changes: 154 additions & 0 deletions action/protocol/staking/contractstake_indexer_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions action/protocol/staking/contractstaking/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type (
}
)

// ErrBucketNotExist is the error when bucket does not exist
var ErrBucketNotExist = errors.New("bucket does not exist")

func (b *Bucket) toProto() *stakingpb.SystemStakingBucket {
if b == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion action/protocol/staking/contractstaking/statemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (cs *ContractStakingStateManager) UpsertBucketType(contractAddr address.Add
// DeleteBucket removes a bucket for a given contract and bucket ID.
func (cs *ContractStakingStateManager) DeleteBucket(contractAddr address.Address, bucketID uint64) error {
_, err := cs.sm.DelState(
bucketTypeNamespaceOption(contractAddr),
contractNamespaceOption(contractAddr),
bucketIDKeyOption(bucketID),
)

Expand Down
Loading