Documentation
¶
Overview ¶
Package chain is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ActionTypeAddStaker() uint64
- func ActionTypeModifyFoundation() uint64
- func ActionTypeModifySysParam() uint64
- func BuildBlock(vm VM, preferred ids.ID) (snowman.Block, error)
- func DeriveSender(dh []byte, sig []byte) (*ecdsa.PublicKey, error)
- func DigestHash(utx UnsignedTransaction) ([]byte, error)
- func GetBalance(db database.KeyValueReader, address common.Address) (uint64, error)
- func GetLastAccepted(db database.KeyValueReader) (ids.ID, error)
- func GetStakeBalance(db database.KeyValueReader, address common.Address) (uint64, error)
- func GetValue(db database.KeyValueReader, key common.Hash) ([]byte, bool, error)
- func HasKey(db database.KeyValueReader, key common.Hash) (bool, error)
- func HasLastAccepted(db database.Database) (bool, error)
- func HasTransaction(db database.KeyValueReader, txID ids.ID) (bool, error)
- func IsRegistered(d *DetailMeta, r *RegisterTx) bool
- func IsRepeated(d *DetailMeta, r *RefreshTx) bool
- func Marshal(source interface{}) ([]byte, error)
- func ModifyBalance(db database.KeyValueReaderWriter, address common.Address, add bool, ...) (uint64, error)
- func ModifyStakeBalance(db database.KeyValueReaderWriter, address common.Address, add bool, ...) (uint64, error)
- func NewActionsState(db database.Database) (*actionsState, error)
- func NewDetailstate(db database.Database) (*detailsState, error)
- func NewPowState(db database.Database) (*powState, error)
- func NewRewardState(db database.Database) (*rewardState, error)
- func NewStakerState(db database.Database) (*stakerState, error)
- func NewSysParamsState(db database.Database, genesis *Genesis) (*sysParams, error)
- func NewUserTypesState(db database.Database) (*userTypesState, error)
- func NewUserstate(db database.Database, metrics prometheus.Registerer) (*usersState, error)
- func NewYieldsState(db database.Database) (*yieldsState, error)
- func PrefixActionsKey(actionID ids.ShortID) (k []byte)
- func PrefixBalanceKey(address common.Address) (k []byte)
- func PrefixBlockKey(blockID ids.ID) (k []byte)
- func PrefixDetailsKey(address common.Address) (k []byte)
- func PrefixPowKey(powType byte, address common.Address) (k []byte)
- func PrefixRewardKey(address common.Address) (k []byte)
- func PrefixStakeKey(address common.Address) (k []byte)
- func PrefixStaker4Key(stakerType byte, address common.Address) (k []byte)
- func PrefixSysParamsKey() (k []byte)
- func PrefixTxKey(txID ids.ID) (k []byte)
- func PrefixTxValueKey(txID ids.ID) (k []byte)
- func PrefixUserTypesKey(id uint64) (k []byte)
- func PrefixUsersKey(address common.Address) (k []byte)
- func PrefixYieldsKey() (k []byte)
- func PutKey(db database.KeyValueWriter, key common.Hash, vmeta *ValueMeta) error
- func RewardGlobalPrefix() (k []byte)
- func RouteStake() uint64
- func SelectRandomValue(db database.Database, seed []byte) []byte
- func SerStake() uint64
- func SetBalance(db database.KeyValueWriter, address common.Address, bal uint64) error
- func SetLastAccepted(db database.KeyValueWriter, block *StatelessBlock) error
- func SetStakeBalance(db database.KeyValueWriter, address common.Address, bal uint64) error
- func SetTransaction(db database.KeyValueWriter, tx *Transaction) error
- func Sign(dh []byte, priv *ecdsa.PrivateKey) ([]byte, error)
- func Unmarshal(source []byte, destination interface{}) (uint16, error)
- func ValidatorStake() uint64
- func ValueHash(v []byte) common.Hash
- func ValueHashString(v []byte) string
- func ValueKey(key common.Hash) (k []byte)
- type ActionMeta
- type ActionsState
- type Activity
- type AddUserTx
- type Airdrop
- type BaseTx
- func (b *BaseTx) Copy() *BaseTx
- func (b *BaseTx) ExecuteBase(g *Genesis) error
- func (b *BaseTx) FeeUnits(g *Genesis) uint64
- func (b *BaseTx) GetBlockID() ids.ID
- func (b *BaseTx) GetMagic() uint64
- func (b *BaseTx) GetPrice() uint64
- func (b *BaseTx) LoadUnits(g *Genesis) uint64
- func (b *BaseTx) SetBlockID(bid ids.ID)
- func (b *BaseTx) SetMagic(magic uint64)
- func (b *BaseTx) SetPrice(price uint64)
- type ClaimTx
- type Context
- type CustomAllocation
- type DetailMeta
- type DetailsState
- type Genesis
- type GovernTx
- type Input
- type KeyValueMeta
- type Mempool
- type MockMempool
- type MockMempoolMockRecorder
- func (mr *MockMempoolMockRecorder) Add(arg0 interface{}) *gomock.Call
- func (mr *MockMempoolMockRecorder) Len() *gomock.Call
- func (mr *MockMempoolMockRecorder) NewTxs(arg0 interface{}) *gomock.Call
- func (mr *MockMempoolMockRecorder) PopMax() *gomock.Call
- func (mr *MockMempoolMockRecorder) Prune(arg0 interface{}) *gomock.Call
- type MockUnsignedTransaction
- func (m *MockUnsignedTransaction) Activity() *Activity
- func (m *MockUnsignedTransaction) Copy() UnsignedTransaction
- func (m *MockUnsignedTransaction) EXPECT() *MockUnsignedTransactionMockRecorder
- func (m *MockUnsignedTransaction) Execute(arg0 *TransactionContext) error
- func (m *MockUnsignedTransaction) ExecuteBase(arg0 *Genesis) error
- func (m *MockUnsignedTransaction) FeeUnits(arg0 *Genesis) uint64
- func (m *MockUnsignedTransaction) GetBlockID() ids.ID
- func (m *MockUnsignedTransaction) GetMagic() uint64
- func (m *MockUnsignedTransaction) GetPrice() uint64
- func (m *MockUnsignedTransaction) LoadUnits(arg0 *Genesis) uint64
- func (m *MockUnsignedTransaction) SetBlockID(arg0 ids.ID)
- func (m *MockUnsignedTransaction) SetMagic(arg0 uint64)
- func (m *MockUnsignedTransaction) SetPrice(arg0 uint64)
- func (m *MockUnsignedTransaction) TypedData() *tdata.TypedData
- type MockUnsignedTransactionMockRecorder
- func (mr *MockUnsignedTransactionMockRecorder) Activity() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) Copy() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) Execute(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) ExecuteBase(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) FeeUnits(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) GetBlockID() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) GetMagic() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) GetPrice() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) LoadUnits(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) SetBlockID(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) SetMagic(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) SetPrice(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) TypedData() *gomock.Call
- type MockVM
- func (m *MockVM) Accepted(arg0 *StatelessBlock)
- func (m *MockVM) EXPECT() *MockVMMockRecorder
- func (m *MockVM) ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error)
- func (m *MockVM) Genesis() *Genesis
- func (m *MockVM) GetStatelessBlock(arg0 ids.ID) (*StatelessBlock, error)
- func (m *MockVM) IsBootstrapped() bool
- func (m *MockVM) Mempool() Mempool
- func (m *MockVM) Rejected(arg0 *StatelessBlock)
- func (m *MockVM) SamaState() SamaState
- func (m *MockVM) State() database.Database
- func (m *MockVM) Verified(arg0 *StatelessBlock)
- type MockVMMockRecorder
- func (mr *MockVMMockRecorder) Accepted(arg0 interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) ExecutionContext(currentTime, parent interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) Genesis() *gomock.Call
- func (mr *MockVMMockRecorder) GetStatelessBlock(arg0 interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) IsBootstrapped() *gomock.Call
- func (mr *MockVMMockRecorder) Mempool() *gomock.Call
- func (mr *MockVMMockRecorder) Rejected(arg0 interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) SamaState() *gomock.Call
- func (mr *MockVMMockRecorder) State() *gomock.Call
- func (mr *MockVMMockRecorder) Verified(arg0 interface{}) *gomock.Call
- type PowMeta
- type PowState
- type ProofMeta
- type ProofTx
- type ProposalTx
- func (p *ProposalTx) Activity() *Activity
- func (p *ProposalTx) Copy() UnsignedTransaction
- func (p *ProposalTx) Execute(t *TransactionContext) error
- func (p *ProposalTx) FeeUnits(genesis *Genesis) uint64
- func (p *ProposalTx) LoadUnits(genesis *Genesis) uint64
- func (p *ProposalTx) TypedData() *tdata.TypedData
- type RefreshTx
- type RegisterTx
- type RewardGlobal
- type RewardMeta
- type RewardState
- type SamaState
- type SetTx
- type StakeTx
- type StakerMeta
- type StakerState
- type StatefulBlock
- type StatelessBlock
- func DummyBlock(tmstp int64, tx *Transaction, vm VM) *StatelessBlock
- func NewBlock(vm VM, parent snowman.Block, tmstp int64, context *Context) *StatelessBlock
- func ParseBlock(source []byte, status choices.Status, vm VM) (*StatelessBlock, error)
- func ParseStatefulBlock(blk *StatefulBlock, source []byte, status choices.Status, vm VM) (*StatelessBlock, error)
- func (b *StatelessBlock) Accept(ctx context.Context) error
- func (b *StatelessBlock) Bytes() []byte
- func (b *StatelessBlock) Height() uint64
- func (b *StatelessBlock) ID() ids.ID
- func (b *StatelessBlock) Parent() ids.ID
- func (b *StatelessBlock) Reject(ctx context.Context) error
- func (b *StatelessBlock) SetChildrenDB(db database.Database) error
- func (b *StatelessBlock) Status() choices.Status
- func (b *StatelessBlock) Timestamp() time.Time
- func (b *StatelessBlock) Verify(ctx context.Context) error
- type SysParams
- type SysParamsMeta
- type Transaction
- func (t *Transaction) Activity() *Activity
- func (t *Transaction) Bytes() []byte
- func (t *Transaction) Copy() *Transaction
- func (t *Transaction) DigestHash() []byte
- func (t *Transaction) Execute(g *Genesis, db database.Database, blk *StatelessBlock, context *Context) error
- func (t *Transaction) ID() ids.ID
- func (t *Transaction) Init(g *Genesis) error
- func (t *Transaction) Sender() common.Address
- func (t *Transaction) Size() uint64
- type TransactionContext
- type TransferTx
- type UnStakeTx
- type UnsignedTransaction
- type UserMeta
- type UserType
- type UserTypesState
- type UsersState
- type VM
- type ValueMeta
- type VoteTx
- type WithdrawnTx
- func (w *WithdrawnTx) Activity() *Activity
- func (w *WithdrawnTx) Copy() UnsignedTransaction
- func (w *WithdrawnTx) Execute(t *TransactionContext) error
- func (w *WithdrawnTx) FeeUnits(genesis *Genesis) uint64
- func (w *WithdrawnTx) LoadUnits(genesis *Genesis) uint64
- func (w *WithdrawnTx) TypedData() *tdata.TypedData
- type YieldMeta
- type YieldsState
Constants ¶
const ( Set = "set" Transfer = "transfer" Stake = "stake" UnStake = "unstake" AddUser = "addUser" Govern = "govern" Proof = "proof" Claim = "claim" Register = "register" Refresh = "refresh" Withdrawn = "withdrawn" Vote = "vote" Proposal = "proposal" )
const ( MinBlockCost = 0 DefaultValueUnitSize = 1 * units.KiB DefaultLookbackWindow = 60 )
const ( LocalPrefix = 0 GlobalPrefix = 1 )
const ( ParamPercRoute = 1 ParamPercSer = 2 ParamPercBase = 3 ParamPercMerit = 4 ParamPercBurn = 5 MinPercentage = 5 MaxPercentage = 95 )
const (
ByteDelimiter byte = '/'
)
const (
UsersCacheSize = 8096
)
Variables ¶
var ( // Genesis Correctness ErrInvalidMagic = errors.New("invalid magic") ErrInvalidBlockRate = errors.New("invalid block rate") // Block Correctness ErrTimestampTooEarly = errors.New("block timestamp too early") ErrTimestampTooLate = errors.New("block timestamp too late") ErrNoTxs = errors.New("no transactions") ErrInvalidCost = errors.New("invalid block cost") ErrInvalidPrice = errors.New("invalid price") ErrInsufficientSurplus = errors.New("insufficient surplus fee") ErrParentBlockNotVerified = errors.New("parent block not verified or accepted") ErrInvalidAccessProof = errors.New("invalid access proof") // Tx Correctness ErrInvalidBlockID = errors.New("invalid blockID") ErrInvalidSignature = errors.New("invalid signature") ErrDuplicateTx = errors.New("duplicate transaction") ErrInsufficientPrice = errors.New("insufficient price") ErrInvalidType = errors.New("invalid tx type") ErrTypedDataKeyMissing = errors.New("typed data key missing") // Execution Correctness ErrValueEmpty = errors.New("value empty") ErrValueTooBig = errors.New("value too big") ErrKeyMissing = errors.New("key missing") ErrInvalidKey = errors.New("key is invalid") ErrKeyExists = errors.New("key already exists") ErrInvalidBalance = errors.New("invalid balance") ErrNonActionable = errors.New("transaction doesn't do anything") ErrBlockTooBig = errors.New("block too big") ErrStakerType = errors.New("staker type err") ErrStakeAmount = errors.New("stake amount err") ErrIDErr = errors.New("id err") ErrEndTimeTooEarly = errors.New("end timestamp too early") ErrEndTimeTooLate = errors.New("end timestamp too late") )
var ( SecondsYear = uint64(364 * 24 * 60 * 60) SecondsMonth = uint64(30 * 24 * 60 * 60) SecondsDay = uint64(24 * 60 * 60) Seconds7Day = uint64(7 * 24 * 60 * 60) SecondsMinute = uint64(60) HoursYear = uint64(364 * 24) )
var EffectiveSecs = uint64(100)
var ErrInvalidKeyFormat = errors.New("invalid key format")
var StakerTypes = []byte{stakerTypeRoute, stakerTypeSer, stakerTypeValidator}
Functions ¶
func ActionTypeAddStaker ¶
func ActionTypeAddStaker() uint64
func ActionTypeModifyFoundation ¶
func ActionTypeModifyFoundation() uint64
func ActionTypeModifySysParam ¶
func ActionTypeModifySysParam() uint64
func DigestHash ¶
func DigestHash(utx UnsignedTransaction) ([]byte, error)
func GetBalance ¶
func GetLastAccepted ¶
func GetLastAccepted(db database.KeyValueReader) (ids.ID, error)
func GetStakeBalance ¶
func HasTransaction ¶
func IsRegistered ¶
func IsRegistered(d *DetailMeta, r *RegisterTx) bool
func IsRepeated ¶
func IsRepeated(d *DetailMeta, r *RefreshTx) bool
func ModifyBalance ¶
func ModifyStakeBalance ¶
func NewActionsState ¶
func NewDetailstate ¶
func NewPowState ¶
func NewRewardState ¶
func NewStakerState ¶
func NewSysParamsState ¶
func NewUserTypesState ¶
func NewUserstate ¶
func NewUserstate(db database.Database, metrics prometheus.Registerer) (*usersState, error)
func NewYieldsState ¶
func PrefixActionsKey ¶
func PrefixBalanceKey ¶
[balancePrefix] + [delimiter] + [address]
func PrefixBlockKey ¶
[blockPrefix] + [delimiter] + [blockID]
func PrefixDetailsKey ¶
func PrefixRewardKey ¶
func PrefixStakeKey ¶
[stakerPrefix] + [delimiter] + [address]
func PrefixSysParamsKey ¶
func PrefixSysParamsKey() (k []byte)
func PrefixTxValueKey ¶
[txValuePrefix] + [delimiter] + [txID]
func PrefixUserTypesKey ¶
func PrefixUsersKey ¶
func PrefixYieldsKey ¶
func PrefixYieldsKey() (k []byte)
func RewardGlobalPrefix ¶
func RewardGlobalPrefix() (k []byte)
func RouteStake ¶
func RouteStake() uint64
func SetBalance ¶
func SetLastAccepted ¶
func SetLastAccepted(db database.KeyValueWriter, block *StatelessBlock) error
func SetStakeBalance ¶
func SetTransaction ¶
func SetTransaction(db database.KeyValueWriter, tx *Transaction) error
func ValidatorStake ¶
func ValidatorStake() uint64
func ValueHashString ¶
Types ¶
type ActionMeta ¶
type ActionMeta struct {
ActionID ids.ShortID `serialize:"true" json:"actionID"`
ActionType uint64 `serialize:"true" json:"actionType"`
StartTime uint64 `serialize:"true" json:"startTime"`
EndTime uint64 `serialize:"true" json:"endTime"`
TxIDs []ids.ID `serialize:"true" json:"txids"`
Voters []common.Address `serialize:"true" json:"voters"`
Key string `serialize:"true" json:"key"`
NewValue string `serialize:"true" json:"newValue"`
}
type ActionsState ¶
type ActionsState interface {
GetActionMeta(actionID ids.ShortID) (*ActionMeta, bool, error)
PutAction(db database.Database, actionID ids.ShortID, pmeta *ActionMeta) error
GetActions() ([]*ActionMeta, error)
DelAction(db database.Database, actionID ids.ShortID) error
ReloadActions(db database.Database) error
CacheActionsCommit() error
CacheActionsAbort() error
GetVotersNum(actionType uint64, key string) (int, ids.ShortID, error)
ProposalRepeat(actionID ids.ShortID, key string, newValue string) error
CheckActionType(actionType uint64) bool
}
type Activity ¶
type Activity struct {
Tmstmp int64 `serialize:"true" json:"timestamp"`
TxID ids.ID `serialize:"true" json:"txId"`
Typ string `serialize:"true" json:"type"`
Sender string `serialize:"true" json:"sender,omitempty"`
Key string `serialize:"true" json:"key,omitempty"`
To string `serialize:"true" json:"to,omitempty"` // common.Address will be 0x000 when not populated
Units uint64 `serialize:"true" json:"units,omitempty"`
StakerType uint64 `serialize:"true" json:"stakerType,omitempty"`
StakeAmount uint64 `serialize:"true" json:"stakeAmount,omitempty"`
StakerAddr string `serialize:"true" json:"stakerAddr,omitempty"`
RewardAmount uint64 `serialize:"true" json:"rewardAmount,omitempty"`
StartTime uint64 `serialize:"true" json:"startTime,omitempty"`
EndTime uint64 `serialize:"true" json:"endTime,omitempty"`
PayAmount uint64 `serialize:"true" json:"payAmout,omitempty"`
Connections uint64 `serialize:"true" json:"connections,omitempty"`
Address string `serialize:"true" json:"address,omitempty"`
ActionID ids.ShortID `serialize:"true" json:"actionID,omitempty"`
ParamType uint64 `serialize:"true" json:"paramType,omitempty"`
Value string `serialize:"true" json:"value,omitempty"`
Netflow uint64 `serialize:"true" json:"netflow,omitempty"`
LocalIP string `serialize:"true" json:"localIP,omitempty"`
MinPort uint64 `serialize:"true" json:"minPort,omitempty"`
MaxPort uint64 `serialize:"true" json:"maxPort,omitempty"`
PublicIP string `serialize:"true" json:"publicIP,omitempty"`
CheckPort uint64 `serialize:"true" json:"checkPort,omitempty"`
Country string `serialize:"true" json:"country,omitempty"`
//DevID string `serialize:"true" json:"devID,omitempty"`
WorkKey string `serialize:"true" json:"workKey,omitempty"`
UserType uint64 `serialize:"true" json:"userType,omitempty"`
ActionType uint64 `serialize:"true" json:"actionType,omitempty"`
}
type AddUserTx ¶
type AddUserTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
StartTime uint64 `serialize:"true" json:"startTime"`
EndTime uint64 `serialize:"true" json:"endTime"`
PayAmount uint64 `serialize:"true" json:"payAmount"`
Connections uint64 `serialize:"true" json:"connections"`
UserType uint64 `serialize:"true" json:"userType"`
Address common.Address `serialize:"true" json:"address"`
}
func (*AddUserTx) Copy ¶
func (c *AddUserTx) Copy() UnsignedTransaction
func (*AddUserTx) Execute ¶
func (a *AddUserTx) Execute(t *TransactionContext) error
type BaseTx ¶
type BaseTx struct {
// BlkID is the ID of a block in the [lookbackWindow].
BlockID ids.ID `serialize:"true" json:"blockId"`
// Magic is a value defined in genesis to protect against replay attacks on
// different VMs.
Magic uint64 `serialize:"true" json:"magic"`
// Price is the value per unit to spend on this transaction.
Price uint64 `serialize:"true" json:"price"`
}
func (*BaseTx) ExecuteBase ¶
func (*BaseTx) GetBlockID ¶
func (*BaseTx) SetBlockID ¶
type ClaimTx ¶
type ClaimTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
RewardAmount uint64 `serialize:"true" json:"reward"`
EndTime uint64 `serialize:"true" json:"endTime"`
}
func (*ClaimTx) Copy ¶
func (c *ClaimTx) Copy() UnsignedTransaction
func (*ClaimTx) Execute ¶
func (c *ClaimTx) Execute(t *TransactionContext) error
type CustomAllocation ¶
type DetailMeta ¶
type DetailMeta struct {
StakerType uint64 `serialize:"true" json:"stakerType"`
Country string `serialize:"true" json:"country"`
LocalIP string `serialize:"true" json:"localIP"`
PublicIP string `serialize:"true" json:"publicIP"`
MinPort uint64 `serialize:"true" json:"minPort"`
MaxPort uint64 `serialize:"true" json:"maxPort"`
CheckPort uint64 `serialize:"true" json:"checkPort"`
WorkKey string `serialize:"true" json:"workKey"`
TxID ids.ID `serialize:"true" json:"txid"`
LastUpdateTime uint64 `serialize:"true" json:"lastUpdateTime"`
WorkAddress common.Address `serialize:"true" json:"workAddress"`
StakeAddress common.Address `serialize:"true" json:"stakeAddress"`
}
type DetailsState ¶
type DetailsState interface {
GetDetailMeta(address common.Address) (*DetailMeta, bool, error)
PutDetail(db database.Database, address common.Address, pmeta *DetailMeta) error
GetDetails() ([]*DetailMeta, error)
DelDetail(db database.Database, address common.Address) error
ReloadDetails(db database.Database) error
CacheDetailsCommit() error
CacheDetailsAbort() error
}
type Genesis ¶
type Genesis struct {
Magic uint64 `serialize:"true" json:"magic"`
// Tx params
BaseTxUnits uint64 `serialize:"true" json:"baseTxUnits"`
// SetTx params
ValueUnitSize uint64 `serialize:"true" json:"valueUnitSize"`
MaxValueSize uint64 `serialize:"true" json:"maxValueSize"`
// Fee Mechanism Params
MinPrice uint64 `serialize:"true" json:"minPrice"`
LookbackWindow int64 `serialize:"true" json:"lookbackWindow"`
TargetBlockRate int64 `serialize:"true" json:"targetBlockRate"` // seconds
TargetBlockSize uint64 `serialize:"true" json:"targetBlockSize"` // units
MaxBlockSize uint64 `serialize:"true" json:"maxBlockSize"` // units
BlockCostEnabled bool `serialize:"true" json:"blockCostEnabled"`
// Allocations
CustomAllocation []*CustomAllocation `serialize:"true" json:"customAllocation"`
AirdropHash string `serialize:"true" json:"airdropHash"`
AirdropUnits uint64 `serialize:"true" json:"airdropUnits"`
//chain Params
TotalTokens uint64 `serialize:"true" json:"totalTokens"`
ClaimMinUnits uint64 `serialize:"true" json:"claimMinUnits"`
ClaimMinInterval uint64 `serialize:"true" json:"claimMinInterval"`
TotalYears uint32 `serialize:"true" json:"totalYears"`
RateSustainYears uint32 `serialize:"true" json:"rateChangeYears"`
ChainCreateTime uint64 `serialize:"true" json:"chainCreateTime"`
MinerPerc uint32 `serialize:"true" json:"minerPerc"`
FoundationPerc uint32 `serialize:"true" json:"foundationPerc"`
RoutePerc uint32 `serialize:"true" json:"routePerc"`
SerPerc uint32 `serialize:"true" json:"serPerc"`
ValidatorPerc uint32 `serialize:"true" json:"validatorPerc"`
BaseSerPerc uint32 `serialize:"true" json:"baseSer"`
MeritSerPerc uint32 `serialize:"true" json:"meritSerPerc"`
BaseRoutePerc uint32 `serialize:"true" json:"baseRoutePerc"`
MeritRoutePerc uint32 `serialize:"true" json:"meritRoutePerc"`
BurnPerc uint32 `serialize:"true" json:"burnPerc"`
RouteStake uint64 `serialize:"true" json:"routeAmount"`
SerStake uint64 `serialize:"true" json:"serAmount"`
MonthCard uint64 `serialize:"true" json:"month"`
SeasonCard uint64 `serialize:"true" json:"season"`
AnnualCard uint64 `serialize:"true" json:"annual"`
MinStakeTime uint64 `serialize:"true" json:"minStakeTime"`
RootAddress string `serialize:"true" json:"rootAddress"`
FoundationAddr string `serialize:"true" json:"foundation"`
}
func DefaultGenesis ¶
func DefaultGenesis() *Genesis
func (*Genesis) StatefulBlock ¶
func (g *Genesis) StatefulBlock() *StatefulBlock
type GovernTx ¶
type GovernTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
ActionID ids.ShortID `serialize:"true" json:"actionID"`
}
func (*GovernTx) Copy ¶
func (g *GovernTx) Copy() UnsignedTransaction
func (*GovernTx) Execute ¶
func (g *GovernTx) Execute(t *TransactionContext) error
type Input ¶
type Input struct {
Typ string `json:"type"`
Key string `json:"key"`
Value []byte `json:"value"`
To common.Address `json:"to"`
Units uint64 `json:"units"`
StakerType uint64 `json:"stakerType"`
StakerAddr common.Address `json:"stakerAddr"`
StakeAmount uint64 `json:"stakeAmount"`
RewardAmount uint64 `json:"rewardAmount"`
ActionID ids.ShortID `json:"actionID"`
LocalIP string `json:"localIP"`
MinPort uint64 `json:"minPort"`
MaxPort uint64 `json:"maxPort"`
PublicIP string `json:"publicIP"`
CheckPort uint64 `json:"checkPort"`
Netflow uint64 `json:"netflow"`
StartTime uint64 `json:"startTime"`
EndTime uint64 `json:"endTime"`
Ser common.Address `json:"ser"`
NewValue string `json:"newValue"`
Country string `json:"country"`
WorkKey string `json:"workKey"`
}
func (*Input) Decode ¶
func (i *Input) Decode() (UnsignedTransaction, error)
type KeyValueMeta ¶
type Mempool ¶
type Mempool interface {
Len() int
Prune(set.Set[ids.ID])
PopMax() (*Transaction, uint64)
Add(*Transaction) bool
NewTxs(uint64) []*Transaction
}
type MockMempool ¶
type MockMempool struct {
// contains filtered or unexported fields
}
MockMempool is a mock of Mempool interface.
func NewMockMempool ¶
func NewMockMempool(ctrl *gomock.Controller) *MockMempool
NewMockMempool creates a new mock instance.
func (*MockMempool) EXPECT ¶
func (m *MockMempool) EXPECT() *MockMempoolMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockMempool) NewTxs ¶
func (m *MockMempool) NewTxs(arg0 uint64) []*Transaction
NewTxs mocks base method.
func (*MockMempool) PopMax ¶
func (m *MockMempool) PopMax() (*Transaction, uint64)
PopMax mocks base method.
type MockMempoolMockRecorder ¶
type MockMempoolMockRecorder struct {
// contains filtered or unexported fields
}
MockMempoolMockRecorder is the mock recorder for MockMempool.
func (*MockMempoolMockRecorder) Add ¶
func (mr *MockMempoolMockRecorder) Add(arg0 interface{}) *gomock.Call
Add indicates an expected call of Add.
func (*MockMempoolMockRecorder) Len ¶
func (mr *MockMempoolMockRecorder) Len() *gomock.Call
Len indicates an expected call of Len.
func (*MockMempoolMockRecorder) NewTxs ¶
func (mr *MockMempoolMockRecorder) NewTxs(arg0 interface{}) *gomock.Call
NewTxs indicates an expected call of NewTxs.
func (*MockMempoolMockRecorder) PopMax ¶
func (mr *MockMempoolMockRecorder) PopMax() *gomock.Call
PopMax indicates an expected call of PopMax.
func (*MockMempoolMockRecorder) Prune ¶
func (mr *MockMempoolMockRecorder) Prune(arg0 interface{}) *gomock.Call
Prune indicates an expected call of Prune.
type MockUnsignedTransaction ¶
type MockUnsignedTransaction struct {
// contains filtered or unexported fields
}
MockUnsignedTransaction is a mock of UnsignedTransaction interface.
func NewMockUnsignedTransaction ¶
func NewMockUnsignedTransaction(ctrl *gomock.Controller) *MockUnsignedTransaction
NewMockUnsignedTransaction creates a new mock instance.
func (*MockUnsignedTransaction) Activity ¶
func (m *MockUnsignedTransaction) Activity() *Activity
Activity mocks base method.
func (*MockUnsignedTransaction) Copy ¶
func (m *MockUnsignedTransaction) Copy() UnsignedTransaction
Copy mocks base method.
func (*MockUnsignedTransaction) EXPECT ¶
func (m *MockUnsignedTransaction) EXPECT() *MockUnsignedTransactionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockUnsignedTransaction) Execute ¶
func (m *MockUnsignedTransaction) Execute(arg0 *TransactionContext) error
Execute mocks base method.
func (*MockUnsignedTransaction) ExecuteBase ¶
func (m *MockUnsignedTransaction) ExecuteBase(arg0 *Genesis) error
ExecuteBase mocks base method.
func (*MockUnsignedTransaction) FeeUnits ¶
func (m *MockUnsignedTransaction) FeeUnits(arg0 *Genesis) uint64
FeeUnits mocks base method.
func (*MockUnsignedTransaction) GetBlockID ¶
func (m *MockUnsignedTransaction) GetBlockID() ids.ID
GetBlockID mocks base method.
func (*MockUnsignedTransaction) GetMagic ¶
func (m *MockUnsignedTransaction) GetMagic() uint64
GetMagic mocks base method.
func (*MockUnsignedTransaction) GetPrice ¶
func (m *MockUnsignedTransaction) GetPrice() uint64
GetPrice mocks base method.
func (*MockUnsignedTransaction) LoadUnits ¶
func (m *MockUnsignedTransaction) LoadUnits(arg0 *Genesis) uint64
LoadUnits mocks base method.
func (*MockUnsignedTransaction) SetBlockID ¶
func (m *MockUnsignedTransaction) SetBlockID(arg0 ids.ID)
SetBlockID mocks base method.
func (*MockUnsignedTransaction) SetMagic ¶
func (m *MockUnsignedTransaction) SetMagic(arg0 uint64)
SetMagic mocks base method.
func (*MockUnsignedTransaction) SetPrice ¶
func (m *MockUnsignedTransaction) SetPrice(arg0 uint64)
SetPrice mocks base method.
func (*MockUnsignedTransaction) TypedData ¶
func (m *MockUnsignedTransaction) TypedData() *tdata.TypedData
TypedData mocks base method.
type MockUnsignedTransactionMockRecorder ¶
type MockUnsignedTransactionMockRecorder struct {
// contains filtered or unexported fields
}
MockUnsignedTransactionMockRecorder is the mock recorder for MockUnsignedTransaction.
func (*MockUnsignedTransactionMockRecorder) Activity ¶
func (mr *MockUnsignedTransactionMockRecorder) Activity() *gomock.Call
Activity indicates an expected call of Activity.
func (*MockUnsignedTransactionMockRecorder) Copy ¶
func (mr *MockUnsignedTransactionMockRecorder) Copy() *gomock.Call
Copy indicates an expected call of Copy.
func (*MockUnsignedTransactionMockRecorder) Execute ¶
func (mr *MockUnsignedTransactionMockRecorder) Execute(arg0 interface{}) *gomock.Call
Execute indicates an expected call of Execute.
func (*MockUnsignedTransactionMockRecorder) ExecuteBase ¶
func (mr *MockUnsignedTransactionMockRecorder) ExecuteBase(arg0 interface{}) *gomock.Call
ExecuteBase indicates an expected call of ExecuteBase.
func (*MockUnsignedTransactionMockRecorder) FeeUnits ¶
func (mr *MockUnsignedTransactionMockRecorder) FeeUnits(arg0 interface{}) *gomock.Call
FeeUnits indicates an expected call of FeeUnits.
func (*MockUnsignedTransactionMockRecorder) GetBlockID ¶
func (mr *MockUnsignedTransactionMockRecorder) GetBlockID() *gomock.Call
GetBlockID indicates an expected call of GetBlockID.
func (*MockUnsignedTransactionMockRecorder) GetMagic ¶
func (mr *MockUnsignedTransactionMockRecorder) GetMagic() *gomock.Call
GetMagic indicates an expected call of GetMagic.
func (*MockUnsignedTransactionMockRecorder) GetPrice ¶
func (mr *MockUnsignedTransactionMockRecorder) GetPrice() *gomock.Call
GetPrice indicates an expected call of GetPrice.
func (*MockUnsignedTransactionMockRecorder) LoadUnits ¶
func (mr *MockUnsignedTransactionMockRecorder) LoadUnits(arg0 interface{}) *gomock.Call
LoadUnits indicates an expected call of LoadUnits.
func (*MockUnsignedTransactionMockRecorder) SetBlockID ¶
func (mr *MockUnsignedTransactionMockRecorder) SetBlockID(arg0 interface{}) *gomock.Call
SetBlockID indicates an expected call of SetBlockID.
func (*MockUnsignedTransactionMockRecorder) SetMagic ¶
func (mr *MockUnsignedTransactionMockRecorder) SetMagic(arg0 interface{}) *gomock.Call
SetMagic indicates an expected call of SetMagic.
func (*MockUnsignedTransactionMockRecorder) SetPrice ¶
func (mr *MockUnsignedTransactionMockRecorder) SetPrice(arg0 interface{}) *gomock.Call
SetPrice indicates an expected call of SetPrice.
func (*MockUnsignedTransactionMockRecorder) TypedData ¶
func (mr *MockUnsignedTransactionMockRecorder) TypedData() *gomock.Call
TypedData indicates an expected call of TypedData.
type MockVM ¶
type MockVM struct {
// contains filtered or unexported fields
}
MockVM is a mock of VM interface.
func NewMockVM ¶
func NewMockVM(ctrl *gomock.Controller) *MockVM
NewMockVM creates a new mock instance.
func (*MockVM) Accepted ¶
func (m *MockVM) Accepted(arg0 *StatelessBlock)
Accepted mocks base method.
func (*MockVM) EXPECT ¶
func (m *MockVM) EXPECT() *MockVMMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockVM) ExecutionContext ¶
func (m *MockVM) ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error)
ExecutionContext mocks base method.
func (*MockVM) GetStatelessBlock ¶
func (m *MockVM) GetStatelessBlock(arg0 ids.ID) (*StatelessBlock, error)
GetStatelessBlock mocks base method.
func (*MockVM) IsBootstrapped ¶
IsBootstrapped mocks base method.
func (*MockVM) Rejected ¶
func (m *MockVM) Rejected(arg0 *StatelessBlock)
Rejected mocks base method.
func (*MockVM) Verified ¶
func (m *MockVM) Verified(arg0 *StatelessBlock)
Verified mocks base method.
type MockVMMockRecorder ¶
type MockVMMockRecorder struct {
// contains filtered or unexported fields
}
MockVMMockRecorder is the mock recorder for MockVM.
func (*MockVMMockRecorder) Accepted ¶
func (mr *MockVMMockRecorder) Accepted(arg0 interface{}) *gomock.Call
Accepted indicates an expected call of Accepted.
func (*MockVMMockRecorder) ExecutionContext ¶
func (mr *MockVMMockRecorder) ExecutionContext(currentTime, parent interface{}) *gomock.Call
ExecutionContext indicates an expected call of ExecutionContext.
func (*MockVMMockRecorder) Genesis ¶
func (mr *MockVMMockRecorder) Genesis() *gomock.Call
Genesis indicates an expected call of Genesis.
func (*MockVMMockRecorder) GetStatelessBlock ¶
func (mr *MockVMMockRecorder) GetStatelessBlock(arg0 interface{}) *gomock.Call
GetStatelessBlock indicates an expected call of GetStatelessBlock.
func (*MockVMMockRecorder) IsBootstrapped ¶
func (mr *MockVMMockRecorder) IsBootstrapped() *gomock.Call
IsBootstrapped indicates an expected call of IsBootstrapped.
func (*MockVMMockRecorder) Mempool ¶
func (mr *MockVMMockRecorder) Mempool() *gomock.Call
Mempool indicates an expected call of Mempool.
func (*MockVMMockRecorder) Rejected ¶
func (mr *MockVMMockRecorder) Rejected(arg0 interface{}) *gomock.Call
Rejected indicates an expected call of Rejected.
func (*MockVMMockRecorder) SamaState ¶
func (mr *MockVMMockRecorder) SamaState() *gomock.Call
SamaState indicates an expected call of SamaState.
func (*MockVMMockRecorder) State ¶
func (mr *MockVMMockRecorder) State() *gomock.Call
State indicates an expected call of State.
func (*MockVMMockRecorder) Verified ¶
func (mr *MockVMMockRecorder) Verified(arg0 interface{}) *gomock.Call
Verified indicates an expected call of Verified.
type PowMeta ¶
type PowMeta struct {
PowType uint64 `serialize:"true" json:"powType"`
TotalTime uint64 `serialize:"true" json:"totalTime"`
Totalflow uint64 `serialize:"true" json:"totalflow"`
LastUpdateTime uint64 `serialize:"true" json:"lastUpdateTime"`
LastUpdateTXID ids.ID `serialize:"true" json:"lastUpdateTxId"`
Miner common.Address `serialize:"true" json:"miner"`
}
type PowState ¶
type PowState interface {
GetCurPow(powType byte) (map[common.Address]*PowMeta, error)
GetPendingPow(powType byte) (map[common.Address]*PowMeta, map[common.Address]*PowMeta, error)
GetPowMeta(powType byte, address common.Address) (*PowMeta, bool, error)
PutPow(db database.Database, powType byte, pmeta *ProofMeta) error
GetPows(powType byte) ([]*PowMeta, error)
DelPow(db database.Database, powType byte, address common.Address) error
ReloadPows(db database.Database) error
CachePowsCommit() error
CachePowsAbort() error
TotalPowTime(powType byte) (uint64, error)
}
type ProofTx ¶
type ProofTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
Netflow uint64 `serialize:"true" json:"netflow"`
StartTime uint64 `serialize:"true" json:"startTime"`
EndTime uint64 `serialize:"true" json:"endTime"`
Ser common.Address `serialize:"true" json:"ser"`
}
func (*ProofTx) Copy ¶
func (p *ProofTx) Copy() UnsignedTransaction
func (*ProofTx) Execute ¶
func (p *ProofTx) Execute(t *TransactionContext) error
type ProposalTx ¶
type ProposalTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
ActionID ids.ShortID `serialize:"true" json:"actionID"`
StartTime uint64 `serialize:"true" json:"startTime"`
EndTime uint64 `serialize:"true" json:"endTime"`
ActionType uint64 `serialize:"true" json:"actionType"`
Key string `serialize:"true" json:"key"`
NewValue string `serialize:"true" json:"newValue"`
}
func (*ProposalTx) Activity ¶
func (p *ProposalTx) Activity() *Activity
func (*ProposalTx) Copy ¶
func (p *ProposalTx) Copy() UnsignedTransaction
func (*ProposalTx) Execute ¶
func (p *ProposalTx) Execute(t *TransactionContext) error
func (*ProposalTx) FeeUnits ¶
func (p *ProposalTx) FeeUnits(genesis *Genesis) uint64
func (*ProposalTx) LoadUnits ¶
func (p *ProposalTx) LoadUnits(genesis *Genesis) uint64
func (*ProposalTx) TypedData ¶
func (p *ProposalTx) TypedData() *tdata.TypedData
type RefreshTx ¶
type RefreshTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
Country string `serialize:"true" json:"country"`
LocalIP string `serialize:"true" json:"localIP"`
PublicIP string `serialize:"true" json:"publicIP"`
MinPort uint64 `serialize:"true" json:"minPort"`
MaxPort uint64 `serialize:"true" json:"maxPort"`
CheckPort uint64 `serialize:"true" json:"checkPort"`
WorkKey string `serialize:"true" json:"workKey"`
}
func (*RefreshTx) Copy ¶
func (r *RefreshTx) Copy() UnsignedTransaction
func (*RefreshTx) Execute ¶
func (r *RefreshTx) Execute(t *TransactionContext) error
type RegisterTx ¶
type RegisterTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
ActionID ids.ShortID `serialize:"true" json:"actionID"`
StakerType uint64 `serialize:"true" json:"stakerType"`
Country string `serialize:"true" json:"country"`
LocalIP string `serialize:"true" json:"localIP"`
PublicIP string `serialize:"true" json:"publicIP"`
MinPort uint64 `serialize:"true" json:"minPort"`
MaxPort uint64 `serialize:"true" json:"maxPort"`
CheckPort uint64 `serialize:"true" json:"checkPort"`
WorkKey string `serialize:"true" json:"workKey"`
StakerAddr common.Address `serialize:"true" json:"stakeAddress"`
}
func (*RegisterTx) Activity ¶
func (r *RegisterTx) Activity() *Activity
func (*RegisterTx) Copy ¶
func (r *RegisterTx) Copy() UnsignedTransaction
func (*RegisterTx) Execute ¶
func (r *RegisterTx) Execute(t *TransactionContext) error
func (*RegisterTx) FeeUnits ¶
func (r *RegisterTx) FeeUnits(g *Genesis) uint64
func (*RegisterTx) LoadUnits ¶
func (r *RegisterTx) LoadUnits(g *Genesis) uint64
func (*RegisterTx) TypedData ¶
func (r *RegisterTx) TypedData() *tdata.TypedData
type RewardGlobal ¶
type RewardMeta ¶
type RewardMeta struct {
YieldReward uint64 `serialize:"true" json:"yieldReward"`
BaseReward uint64 `serialize:"true" json:"BaseReward"`
MeritReward uint64 `serialize:"true" json:"meritReward"`
LastOprTime uint64 `serialize:"true" json:"lastOprTime"`
LastOprTXID ids.ID `serialize:"true" json:"lastOprTxId"`
LastClaimTime uint64 `serialize:"true" json:"lastClaimTime"`
LastClaimTXID ids.ID `serialize:"true" json:"lastClaimTxId"`
RewardAddr common.Address `serialize:"true" json:"rewardAddr"`
}
type RewardState ¶
type RewardState interface {
GetRewardMeta(address common.Address) (*RewardMeta, bool, error)
UpdateReward(db database.Database, pG *RewardGlobal, pmeta *RewardMeta) error
UpdateOwner(db database.Database, pmeta *RewardMeta) error
UpdateGlobal(db database.Database, pG *RewardGlobal) error
GetRewards() ([]*RewardMeta, error)
DelReward(db database.Database, address common.Address) error
ReloadRewards(db database.Database) error
CacheRewardsCommit() error
CacheRewardsAbort() error
GetLastUpdateTime() (uint64, error)
GetLastClaimTime(address common.Address) (uint64, error)
}
type SamaState ¶
type SamaState interface {
SysParams
StakerState
RewardState
PowState
YieldsState
UsersState
DetailsState
ActionsState
UserTypesState
Commit() error
Abort() error
CalcReward(claimerType byte, address common.Address, endTime uint64) (uint64, uint64, uint64, error)
CheckPayAmount(db database.Database, userType uint64, amount uint64, startTime uint64, endTime uint64) (bool, error)
DealStakeTx(db database.Database, staker *StakerMeta) error
DealUnStakeTx(db database.Database, stakerType byte, address common.Address, txID ids.ID, endTime uint64) error
DealAddUserTx(db database.Database, txID ids.ID, blkTime uint64, user *UserMeta) error
UpdateNodeParams(db database.Database, detail *DetailMeta) error
UpdateStakerReward(db database.Database, stakerType byte, address common.Address, txID ids.ID, endTime uint64) error
UpdateFoundationReward(db database.Database, address common.Address, txID ids.ID, endTime uint64) error
IsBeConfirmed(actionType uint64, key string) (bool, ids.ShortID, error)
ProposalStatus(actionID ids.ShortID) (bool, error)
IsValidWorkAddress(address common.Address) (bool, byte, error)
CheckClaimAddress(address common.Address) (bool, byte, error)
}
func SamaNew ¶
func SamaNew(db database.Database, metrics prometheus.Registerer, g *Genesis) (SamaState, error)
type SetTx ¶
type SetTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
Value []byte `serialize:"true" json:"value"`
}
func (*SetTx) Copy ¶
func (s *SetTx) Copy() UnsignedTransaction
func (*SetTx) Execute ¶
func (s *SetTx) Execute(t *TransactionContext) error
type StakeTx ¶
type StakeTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
StakerType uint64 `serialize:"true" json:"stakerType"`
StakeAmount uint64 `serialize:"true" json:"stakeAmount"`
StakerAddr common.Address `serialize:"true" json:"stakerAddr"`
}
func (*StakeTx) Copy ¶
func (s *StakeTx) Copy() UnsignedTransaction
func (*StakeTx) Execute ¶
func (s *StakeTx) Execute(t *TransactionContext) error
type StakerMeta ¶
type StakerState ¶
type StakerState interface {
GetPendingStakers(stakerType byte) (map[common.Address]*StakerMeta, map[common.Address]*StakerMeta, error)
GetStakerMeta(stakerType byte, address common.Address) (*StakerMeta, bool, error)
PutStaker(db database.Database, pmeta *StakerMeta) error
GetStakers(stakerType byte) ([]*StakerMeta, error)
DelStaker(db database.Database, stakerType byte, address common.Address) error
ReloadStakers(db database.Database) error
CacheStakersCommit() error
CacheStakersAbort() error
GetStakersNum() (int, int, int)
IsRoute(address common.Address) (bool, error)
IsSer(address common.Address) (bool, error)
IsValidator(address common.Address) (bool, error)
IsStaker(address common.Address) (bool, byte, error)
}
type StatefulBlock ¶
type StatefulBlock struct {
Prnt ids.ID `serialize:"true" json:"parent"`
Tmstmp int64 `serialize:"true" json:"timestamp"`
Hght uint64 `serialize:"true" json:"height"`
Price uint64 `serialize:"true" json:"price"`
Cost uint64 `serialize:"true" json:"cost"`
AccessProof common.Hash `serialize:"true" json:"accessProof"`
Txs []*Transaction `serialize:"true" json:"txs"`
}
func GetBlock ¶
func GetBlock(db database.KeyValueReader, bid ids.ID) (*StatefulBlock, error)
func (*StatefulBlock) Dummy ¶
func (b *StatefulBlock) Dummy() bool
type StatelessBlock ¶
type StatelessBlock struct {
*StatefulBlock `serialize:"true" json:"block"`
// contains filtered or unexported fields
}
Stateless is defined separately from "Block" in case external packages needs use the stateful block without mocking VM or parent block
func DummyBlock ¶
func DummyBlock(tmstp int64, tx *Transaction, vm VM) *StatelessBlock
DummyBlock is used for validating new txs and some tests
func ParseBlock ¶
func ParseStatefulBlock ¶
func ParseStatefulBlock( blk *StatefulBlock, source []byte, status choices.Status, vm VM, ) (*StatelessBlock, error)
func (*StatelessBlock) Accept ¶
func (b *StatelessBlock) Accept(ctx context.Context) error
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) ID ¶
func (b *StatelessBlock) ID() ids.ID
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) Reject ¶
func (b *StatelessBlock) Reject(ctx context.Context) error
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) SetChildrenDB ¶
func (b *StatelessBlock) SetChildrenDB(db database.Database) error
func (*StatelessBlock) Status ¶
func (b *StatelessBlock) Status() choices.Status
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) Timestamp ¶
func (b *StatelessBlock) Timestamp() time.Time
implements "snowman.Block"
type SysParams ¶
type SysParams interface {
ReloadParams(db database.Database) error
ModifyParams(db database.Database, key string, newValue string, txID ids.ID, updateTime uint64) error
CacheParamsCommit() error
CacheParamsAbort() error
GetChainSymbol() string
GetChainTokenAmount() uint64
GetPercRoute() uint32
GetPercSer() uint32
GetPercValidator() uint32
GetRoutePercBase() uint32
GetRoutePercMerit() uint32
GetSerPercBase() uint32
GetSerPercMerit() uint32
GetPercBurn() uint32
GetPercFoundation() uint32
GetTotalYears() uint32
GetRateSustainYears() uint32
GetChainCreateTime() uint64
GetMonthCardPrice() uint64
GetSeasonCardPrice() uint64
GetAnnualCardPrice() uint64
GetMinStakeTime() uint64
GetRootAddress() string
GetSysParams() *SysParamsMeta
CompCurParam(key string, newValue string) error
GetFoundationAddress() string
}
type SysParamsMeta ¶
type SysParamsMeta struct {
Symbol string `serialize:"true" json:"symbol"`
TotalTokens uint64 `serialize:"true" json:"totalTokens"`
ClaimMinUnits uint64 `serialize:"true" json:"claimMinUnits"`
ClaimMinInterval uint64 `serialize:"true" json:"claimMinInterval"`
TotalYears uint32 `serialize:"true" json:"totalYears"`
RateSustainYears uint32 `serialize:"true" json:"rateChangeYears"`
ChainCreateTime uint64 `serialize:"true" json:"chainCreateTime"`
MinerPerc uint32 `serialize:"true" json:"minerPerc"`
FoundationPerc uint32 `serialize:"true" json:"foundationPerc"`
RoutePerc uint32 `serialize:"true" json:"routePerc"`
SerPerc uint32 `serialize:"true" json:"serPerc"`
ValidatorPerc uint32 `serialize:"true" json:"validatorPerc"`
BaseSerPerc uint32 `serialize:"true" json:"baseSer"`
MeritSerPerc uint32 `serialize:"true" json:"meritSerPerc"`
BaseRoutePerc uint32 `serialize:"true" json:"baseRoutePerc"`
MeritRoutePerc uint32 `serialize:"true" json:"meritRoutePerc"`
RouteStakeAmount uint64 `serialize:"true" json:"routeAmount"`
SerStakeAmount uint64 `serialize:"true" json:"serAmount"`
MinStakeTime uint64 `serialize:"true" json:"minStakeTime"`
MonthCard uint64 `serialize:"true" json:"month"`
SeasonCard uint64 `serialize:"true" json:"season"`
AnnualCard uint64 `serialize:"true" json:"annual"`
BurnPerc uint32 `serialize:"true" json:"burnPerc"`
RootAddress string `serialize:"true" json:"rootAddress"`
FoundationAddr string `serialize:"true" json:"foundation"`
UpdateTime uint64 `serialize:"true" json:"updateTime"`
UpdateTxID ids.ID `serialize:"true" json:"updateTxId"`
}
type Transaction ¶
type Transaction struct {
UnsignedTransaction `serialize:"true" json:"unsignedTransaction"`
Signature []byte `serialize:"true" json:"signature"`
// contains filtered or unexported fields
}
func NewTx ¶
func NewTx(utx UnsignedTransaction, sig []byte) *Transaction
func (*Transaction) Activity ¶
func (t *Transaction) Activity() *Activity
func (*Transaction) Bytes ¶
func (t *Transaction) Bytes() []byte
func (*Transaction) Copy ¶
func (t *Transaction) Copy() *Transaction
func (*Transaction) DigestHash ¶
func (t *Transaction) DigestHash() []byte
func (*Transaction) Execute ¶
func (t *Transaction) Execute(g *Genesis, db database.Database, blk *StatelessBlock, context *Context) error
func (*Transaction) ID ¶
func (t *Transaction) ID() ids.ID
func (*Transaction) Init ¶
func (t *Transaction) Init(g *Genesis) error
func (*Transaction) Sender ¶
func (t *Transaction) Sender() common.Address
func (*Transaction) Size ¶
func (t *Transaction) Size() uint64
type TransactionContext ¶
type TransferTx ¶
type TransferTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
// To is the recipient of the [Units].
To common.Address `serialize:"true" json:"to"`
// Units are transferred to [To].
Units uint64 `serialize:"true" json:"units"`
}
func (*TransferTx) Activity ¶
func (t *TransferTx) Activity() *Activity
func (*TransferTx) Copy ¶
func (t *TransferTx) Copy() UnsignedTransaction
func (*TransferTx) Execute ¶
func (t *TransferTx) Execute(c *TransactionContext) error
func (*TransferTx) TypedData ¶
func (t *TransferTx) TypedData() *tdata.TypedData
type UnStakeTx ¶
type UnStakeTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
RewardAmount uint64 `serialize:"true" json:"rewardAmount"`
StakerType uint64 `serialize:"true" json:"stakerType"`
EndTime uint64 `serialize:"true" json:"endTime"`
}
func (*UnStakeTx) Copy ¶
func (u *UnStakeTx) Copy() UnsignedTransaction
func (*UnStakeTx) Execute ¶
func (u *UnStakeTx) Execute(t *TransactionContext) error
type UnsignedTransaction ¶
type UnsignedTransaction interface {
Copy() UnsignedTransaction
GetBlockID() ids.ID
GetMagic() uint64
GetPrice() uint64
SetBlockID(ids.ID)
SetMagic(uint64)
SetPrice(uint64)
FeeUnits(*Genesis) uint64 // number of units to mine tx
LoadUnits(*Genesis) uint64 // units that should impact fee rate
ExecuteBase(*Genesis) error
Execute(*TransactionContext) error
TypedData() *tdata.TypedData
Activity() *Activity
}
func ParseTypedData ¶
func ParseTypedData(td *tdata.TypedData) (UnsignedTransaction, error)
type UserMeta ¶
type UserMeta struct {
StartTime uint64 `serialize:"true" json:"startTime"`
EndTime uint64 `serialize:"true" json:"endTime"`
Connections uint64 `serialize:"true" json:"connections"`
PayAmount uint64 `serialize:"true" json:"payAmount"`
TxsID []ids.ID `serialize:"true" json:"txsid"`
UserType uint64 `serialize:"true" json:"userType"`
Address common.Address `serialize:"true" json:"address"`
}
type UserTypesState ¶
type UserTypesState interface {
GetUserType(db database.Database, id uint64) (*UserType, bool, error)
AddUserType(db database.Database, pmeta *UserType) error
DelUserType(db database.Database, id uint64) error
GetUserTypes(db database.Database) (map[uint64]*UserType, error)
ReloadUserTypes(db database.Database) error
CacheUserTypesCommit() error
CacheUserTypesAbort() error
CheckUserType(id uint64) bool
CheckFee(id uint64, fee uint64) bool
}
type UsersState ¶
type UsersState interface {
GetUserMeta(db database.Database, address common.Address) (*UserMeta, bool, error)
PutUser(db database.Database, pmeta *UserMeta) error
DelUser(db database.Database, address common.Address) error
GetUsers(db database.Database) ([]*UserMeta, error)
ReloadUsers(db database.Database) error
CacheUsersCommit() error
CacheUsersAbort() error
}
type VM ¶
type VM interface {
Genesis() *Genesis
IsBootstrapped() bool
State() database.Database
Mempool() Mempool
GetStatelessBlock(ids.ID) (*StatelessBlock, error)
ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error)
Verified(*StatelessBlock)
Rejected(*StatelessBlock)
Accepted(*StatelessBlock)
SamaState() SamaState
}
type ValueMeta ¶
type ValueMeta struct {
Size uint64 `serialize:"true" json:"size"`
TxID ids.ID `serialize:"true" json:"txId"`
Created uint64 `serialize:"true" json:"created"`
}
func GetValueMeta ¶
type VoteTx ¶
type VoteTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
ActionID ids.ShortID `serialize:"true" json:"actionID"`
}
func (*VoteTx) Copy ¶
func (v *VoteTx) Copy() UnsignedTransaction
func (*VoteTx) Execute ¶
func (v *VoteTx) Execute(t *TransactionContext) error
type WithdrawnTx ¶
type WithdrawnTx struct {
*BaseTx `serialize:"true" json:"baseTx"`
ActionID ids.ShortID `serialize:"true" json:"actionID"`
}
func (*WithdrawnTx) Activity ¶
func (w *WithdrawnTx) Activity() *Activity
func (*WithdrawnTx) Copy ¶
func (w *WithdrawnTx) Copy() UnsignedTransaction
func (*WithdrawnTx) Execute ¶
func (w *WithdrawnTx) Execute(t *TransactionContext) error
func (*WithdrawnTx) FeeUnits ¶
func (w *WithdrawnTx) FeeUnits(genesis *Genesis) uint64
func (*WithdrawnTx) LoadUnits ¶
func (w *WithdrawnTx) LoadUnits(genesis *Genesis) uint64
func (*WithdrawnTx) TypedData ¶
func (w *WithdrawnTx) TypedData() *tdata.TypedData
Source Files
¶
- action_status.go
- activity.go
- add_user_tx.go
- base_tx.go
- block.go
- builder.go
- claim_tx.go
- codec.go
- common_tx.go
- crypto.go
- decoder.go
- errors.go
- genesis.go
- govern_tx.go
- mempool.go
- mempool_mock.go
- node_params.go
- pow_status.go
- proof_tx.go
- proposal_tx.go
- refresh_tx.go
- register_tx.go
- reward_status.go
- set_tx.go
- stake_status.go
- stake_tx.go
- state.go
- storage.go
- system_params.go
- transfer_tx.go
- tx.go
- unsigned_tx.go
- unsigned_tx_mock.go
- unstake_tx.go
- users_status.go
- users_type.go
- vm.go
- vm_mock.go
- vote_tx.go
- withdrawn_tx.go
- yields_status.go