github.com/lino-network/lino@v0.6.11/x/validator/manager/hooks.go (about)

     1  package manager
     2  
     3  import (
     4  	sdk "github.com/cosmos/cosmos-sdk/types"
     5  
     6  	linotypes "github.com/lino-network/lino/types"
     7  	votemn "github.com/lino-network/lino/x/vote/manager"
     8  )
     9  
    10  func (vm ValidatorManager) AfterAddingStake(ctx sdk.Context, username linotypes.AccountKey) sdk.Error {
    11  	return vm.onStakeChange(ctx, username)
    12  }
    13  
    14  func (vm ValidatorManager) AfterSubtractingStake(ctx sdk.Context, username linotypes.AccountKey) sdk.Error {
    15  	return vm.onStakeChange(ctx, username)
    16  }
    17  
    18  func (vm ValidatorManager) AfterSlashing(ctx sdk.Context, username linotypes.AccountKey) sdk.Error {
    19  	return nil
    20  }
    21  
    22  type Hooks struct {
    23  	vm ValidatorManager
    24  }
    25  
    26  var _ votemn.StakingHooks = Hooks{}
    27  
    28  // Return the wrapper struct
    29  func (vm ValidatorManager) Hooks() Hooks {
    30  	return Hooks{vm}
    31  }
    32  
    33  func (h Hooks) AfterAddingStake(ctx sdk.Context, username linotypes.AccountKey) sdk.Error {
    34  	return h.vm.AfterAddingStake(ctx, username)
    35  }
    36  
    37  func (h Hooks) AfterSubtractingStake(ctx sdk.Context, username linotypes.AccountKey) sdk.Error {
    38  	return h.vm.AfterSubtractingStake(ctx, username)
    39  }
    40  
    41  func (h Hooks) AfterSlashing(ctx sdk.Context, username linotypes.AccountKey) sdk.Error {
    42  	return h.vm.AfterSlashing(ctx, username)
    43  }