stake

package
v0.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_reward_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AddressOrderDelegatees

type AddressOrderDelegatees []*Delegatee

func (AddressOrderDelegatees) Len

func (vs AddressOrderDelegatees) Len() int

func (AddressOrderDelegatees) Less

func (vs AddressOrderDelegatees) Less(i, j int) bool

ascending order by address

func (AddressOrderDelegatees) Swap

func (vs AddressOrderDelegatees) Swap(i, j int)

type BlockMarker

type BlockMarker struct {
	BlockHeights []int64 `json:"blockHeights"`
	// contains filtered or unexported fields
}

func (*BlockMarker) CountInWindow

func (bm *BlockMarker) CountInWindow(h0, h1 int64, rewin bool) int

CountInWindow() returns the number of marked height in [startHeight, endHeight]. If `rewin` is true, all heights before `h0` is removed after counting.

func (*BlockMarker) Mark

func (bm *BlockMarker) Mark(height int64) xerrors.XError

type Delegatee

type Delegatee struct {
	Addr   types.Address   `json:"address"`
	PubKey bytes2.HexBytes `json:"pubKey"`

	SelfPower    int64 `json:"selfPower,string"`
	TotalPower   int64 `json:"totalPower,string"`
	SlashedPower int64 `json:"slashedPower,string"`

	Stakes []*Stake `json:"stakes"`

	NotSignedHeights *BlockMarker `json:"notSignedBlocks"`
	// contains filtered or unexported fields
}

func NewDelegatee

func NewDelegatee(addr types.Address, pubKey bytes2.HexBytes) *Delegatee

func (*Delegatee) AddStake

func (delegatee *Delegatee) AddStake(stakes ...*Stake) xerrors.XError

func (*Delegatee) Decode

func (delegatee *Delegatee) Decode(d []byte) xerrors.XError

func (*Delegatee) DelAllStakes

func (delegatee *Delegatee) DelAllStakes() []*Stake

func (*Delegatee) DelStake

func (delegatee *Delegatee) DelStake(txhash bytes2.HexBytes) *Stake

func (*Delegatee) DelStakeByIdx

func (delegatee *Delegatee) DelStakeByIdx(idx int) *Stake

func (*Delegatee) DoSlash

func (delegatee *Delegatee) DoSlash(ratio int64) int64

func (*Delegatee) Encode

func (delegatee *Delegatee) Encode() ([]byte, xerrors.XError)

func (*Delegatee) FindStake

func (delegatee *Delegatee) FindStake(txhash bytes2.HexBytes) (int, *Stake)

func (*Delegatee) GetAddress

func (delegatee *Delegatee) GetAddress() types.Address

func (*Delegatee) GetAllStakes

func (delegatee *Delegatee) GetAllStakes() []*Stake

func (*Delegatee) GetNotSignedBlockCount

func (delegatee *Delegatee) GetNotSignedBlockCount(h0, h1 int64) int

GetNotSignedBlockCount() returns the number of marked height in [h0, h1].

func (*Delegatee) GetSelfPower

func (delegatee *Delegatee) GetSelfPower() int64

func (*Delegatee) GetStake

func (delegatee *Delegatee) GetStake(idx int) *Stake

func (*Delegatee) GetTotalPower

func (delegatee *Delegatee) GetTotalPower() int64

func (*Delegatee) Key

func (delegatee *Delegatee) Key() v1.LedgerKey

func (*Delegatee) ProcessNotSignedBlock

func (delegatee *Delegatee) ProcessNotSignedBlock(height int64) xerrors.XError

func (*Delegatee) SelfStakeRatio

func (delegatee *Delegatee) SelfStakeRatio(added int64) int64

func (*Delegatee) StakesLen

func (delegatee *Delegatee) StakesLen() int

func (*Delegatee) StakesOf

func (delegatee *Delegatee) StakesOf(addr types.Address) []*Stake

func (*Delegatee) String

func (delegatee *Delegatee) String() string

func (*Delegatee) SumPower

func (delegatee *Delegatee) SumPower() int64

func (*Delegatee) SumPowerOf

func (delegatee *Delegatee) SumPowerOf(addr types.Address) int64

type DelegateeArray

type DelegateeArray []*Delegatee

func (DelegateeArray) Find

func (delgs DelegateeArray) Find(addr types.Address) (int, *Delegatee)

func (DelegateeArray) SumTotalPower

func (delgs DelegateeArray) SumTotalPower() int64

type InitStake

type InitStake struct {
	PubKeys bytes.HexBytes
	Stakes  []*Stake
}

type PowerOrderDelegatees

type PowerOrderDelegatees []*Delegatee

func (PowerOrderDelegatees) Len

func (vs PowerOrderDelegatees) Len() int

func (PowerOrderDelegatees) Less

func (vs PowerOrderDelegatees) Less(i, j int) bool

descending order by TotalPower

func (PowerOrderDelegatees) Swap

func (vs PowerOrderDelegatees) Swap(i, j int)

type Reward

type Reward struct {
	// contains filtered or unexported fields
}

func NewReward

func NewReward(addr types.Address) *Reward

func (*Reward) Address

func (rwd *Reward) Address() types.Address

func (*Reward) Decode

func (rwd *Reward) Decode(d []byte) xerrors.XError

func (*Reward) Encode

func (rwd *Reward) Encode() ([]byte, xerrors.XError)

func (*Reward) GetCumulated

func (rwd *Reward) GetCumulated() *uint256.Int

func (*Reward) GetIssued

func (rwd *Reward) GetIssued() *uint256.Int

func (*Reward) GetSlashed

func (rwd *Reward) GetSlashed() *uint256.Int

func (*Reward) GetWithdrawn

func (rwd *Reward) GetWithdrawn() *uint256.Int

func (*Reward) Height

func (rwd *Reward) Height() int64

func (*Reward) Issue

func (rwd *Reward) Issue(r *uint256.Int, h int64) xerrors.XError

func (*Reward) Key

func (rwd *Reward) Key() v1.LedgerKey

func (*Reward) MarshalJSON

func (rwd *Reward) MarshalJSON() ([]byte, error)

func (*Reward) Slash

func (rwd *Reward) Slash(r *uint256.Int, h int64) xerrors.XError

func (*Reward) String

func (rwd *Reward) String() string

func (*Reward) UnmarshalJSON

func (rwd *Reward) UnmarshalJSON(d []byte) error

func (*Reward) Withdraw

func (rwd *Reward) Withdraw(r *uint256.Int, h int64) xerrors.XError

type RewardProto

type RewardProto struct {
	Address    []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	XIssued    []byte `protobuf:"bytes,2,opt,name=_issued,json=Issued,proto3" json:"_issued,omitempty"`
	XWithdrawn []byte `protobuf:"bytes,3,opt,name=_withdrawn,json=Withdrawn,proto3" json:"_withdrawn,omitempty"`
	XSlashed   []byte `protobuf:"bytes,4,opt,name=_slashed,json=Slashed,proto3" json:"_slashed,omitempty"`
	XCumulated []byte `protobuf:"bytes,5,opt,name=_cumulated,json=Cumulated,proto3" json:"_cumulated,omitempty"`
	Height     int64  `protobuf:"varint,6,opt,name=height,proto3" json:"height,omitempty"`
	// contains filtered or unexported fields
}

func (*RewardProto) Descriptor deprecated

func (*RewardProto) Descriptor() ([]byte, []int)

Deprecated: Use RewardProto.ProtoReflect.Descriptor instead.

func (*RewardProto) GetAddress

func (x *RewardProto) GetAddress() []byte

func (*RewardProto) GetHeight

func (x *RewardProto) GetHeight() int64

func (*RewardProto) GetXCumulated

func (x *RewardProto) GetXCumulated() []byte

func (*RewardProto) GetXIssued

func (x *RewardProto) GetXIssued() []byte

func (*RewardProto) GetXSlashed

func (x *RewardProto) GetXSlashed() []byte

func (*RewardProto) GetXWithdrawn

func (x *RewardProto) GetXWithdrawn() []byte

func (*RewardProto) ProtoMessage

func (*RewardProto) ProtoMessage()

func (*RewardProto) ProtoReflect

func (x *RewardProto) ProtoReflect() protoreflect.Message

func (*RewardProto) Reset

func (x *RewardProto) Reset()

func (*RewardProto) String

func (x *RewardProto) String() string

type Stake

type Stake struct {
	From types.Address `json:"owner"`
	To   types.Address `json:"to"`

	TxHash       abytes.HexBytes `json:"txhash"`
	StartHeight  int64           `json:"startHeight,string"`
	RefundHeight int64           `json:"refundHeight,string"`

	Power int64 `json:"power,string"`
	// contains filtered or unexported fields
}

func NewStakeWithAmount

func NewStakeWithAmount(owner, to types.Address, amt *uint256.Int, startHeight int64, txhash abytes.HexBytes) (*Stake, xerrors.XError)

func NewStakeWithPower

func NewStakeWithPower(owner, to types.Address, power int64, startHeight int64, txhash abytes.HexBytes) *Stake

func (*Stake) Clone

func (s *Stake) Clone() *Stake

func (*Stake) Decode

func (s *Stake) Decode(d []byte) xerrors.XError

func (*Stake) Encode

func (s *Stake) Encode() ([]byte, xerrors.XError)

func (*Stake) Equal

func (s *Stake) Equal(o *Stake) bool

func (*Stake) IsSelfStake

func (s *Stake) IsSelfStake() bool

func (*Stake) Key

func (s *Stake) Key() v1.LedgerKey

func (*Stake) String

func (s *Stake) String() string

type StakeCtrler

type StakeCtrler struct {
	// contains filtered or unexported fields
}

func NewStakeCtrler

func NewStakeCtrler(config *cfg.Config, govHandler ctrlertypes.IGovHandler, logger tmlog.Logger) (*StakeCtrler, xerrors.XError)

func (*StakeCtrler) BeginBlock

func (ctrler *StakeCtrler) BeginBlock(blockCtx *ctrlertypes.BlockContext) ([]abcitypes.Event, xerrors.XError)

BeginBlock are called in BeatozApp::BeginBlock

func (*StakeCtrler) Close

func (ctrler *StakeCtrler) Close() xerrors.XError

func (*StakeCtrler) Commit

func (ctrler *StakeCtrler) Commit() ([]byte, int64, xerrors.XError)

func (*StakeCtrler) DelegatedPowerOf

func (ctrler *StakeCtrler) DelegatedPowerOf(addr types.Address) int64

DelegatedPowerOf is used only to test

func (*StakeCtrler) Delegatee

func (ctrler *StakeCtrler) Delegatee(addr types.Address) *Delegatee

Delegatee is used only to test

func (*StakeCtrler) DoPunish

func (ctrler *StakeCtrler) DoPunish(evi *abcitypes.Evidence, slashRatio int64) (int64, xerrors.XError)

func (*StakeCtrler) DoReward

func (ctrler *StakeCtrler) DoReward(height int64, votes []abcitypes.VoteInfo) (*uint256.Int, xerrors.XError)

DoReward is only used to test

func (*StakeCtrler) EndBlock

func (ctrler *StakeCtrler) EndBlock(ctx *ctrlertypes.BlockContext) ([]abcitypes.Event, xerrors.XError)

func (*StakeCtrler) ExecuteTrx

func (ctrler *StakeCtrler) ExecuteTrx(ctx *ctrlertypes.TrxContext) xerrors.XError

func (*StakeCtrler) InitLedger

func (ctrler *StakeCtrler) InitLedger(req interface{}) xerrors.XError

func (*StakeCtrler) IsValidator

func (ctrler *StakeCtrler) IsValidator(addr types.Address) bool

func (*StakeCtrler) Query

func (ctrler *StakeCtrler) Query(req abcitypes.RequestQuery) ([]byte, xerrors.XError)

func (*StakeCtrler) ReadFrozenStakes

func (ctrler *StakeCtrler) ReadFrozenStakes() []*Stake

ReadFrozenStakes is used only to test

func (*StakeCtrler) ReadTotalAmount

func (ctrler *StakeCtrler) ReadTotalAmount() *uint256.Int

ReadTotalAmount is used only to test

func (*StakeCtrler) ReadTotalPower

func (ctrler *StakeCtrler) ReadTotalPower() int64

ReadTotalPower is used only to test

func (*StakeCtrler) SelfPowerOf

func (ctrler *StakeCtrler) SelfPowerOf(addr types.Address) int64

SelfPowerOf is used only to test

func (*StakeCtrler) TotalPowerOf

func (ctrler *StakeCtrler) TotalPowerOf(addr types.Address) int64

TotalPowerOf is used only to test

func (*StakeCtrler) UpdateValidators

func (ctrler *StakeCtrler) UpdateValidators(maxVals int) []abcitypes.ValidatorUpdate

func (*StakeCtrler) ValidateTrx

func (ctrler *StakeCtrler) ValidateTrx(ctx *ctrlertypes.TrxContext) xerrors.XError

func (*StakeCtrler) Validators

func (ctrler *StakeCtrler) Validators() ([]*abcitypes.Validator, int64)

IStakeHandler's methods

type StakeLimiter

type StakeLimiter struct {
	// contains filtered or unexported fields
}

StakeLimiter limits the amount of stake changes in one block.

func NewStakeLimiter

func NewStakeLimiter(vals PowerOrderDelegatees, maxValCnt, indiLimitRatio, upLimitRatio int64) *StakeLimiter

func (*StakeLimiter) CheckLimit

func (sl *StakeLimiter) CheckLimit(delg *Delegatee, changePower int64) xerrors.XError

func (*StakeLimiter) Reset

func (sl *StakeLimiter) Reset(vals PowerOrderDelegatees, maxValCnt, indiLimitRatio, upLimitRatio int64)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL