chain

package
v0.0.0-...-71ead4b Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package chain is a generated GoMock package.

Index

Constants

View Source
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"
)
View Source
const (
	MinBlockCost          = 0
	DefaultValueUnitSize  = 1 * units.KiB
	DefaultLookbackWindow = 60
)
View Source
const (
	LocalPrefix  = 0
	GlobalPrefix = 1
)
View Source
const (
	ParamPercRoute = 1
	ParamPercSer   = 2
	ParamPercBase  = 3
	ParamPercMerit = 4
	ParamPercBurn  = 5

	MinPercentage = 5
	MaxPercentage = 95
)
View Source
const (
	ByteDelimiter byte = '/'
)
View Source
const (
	UsersCacheSize = 8096
)

Variables

View Source
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")
	ErrUnauthorized   = errors.New("sender is not authorized")
	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")
)
View Source
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)
)
View Source
var EffectiveSecs = uint64(100)
View Source
var ErrInvalidKeyFormat = errors.New("invalid key format")
View Source
var StakerTypes = []byte{stakerTypeRoute, stakerTypeSer, stakerTypeValidator}

Functions

func ActionTypeAddStaker

func ActionTypeAddStaker() uint64

func ActionTypeModifyFoundation

func ActionTypeModifyFoundation() uint64

func ActionTypeModifySysParam

func ActionTypeModifySysParam() uint64

func BuildBlock

func BuildBlock(vm VM, preferred ids.ID) (snowman.Block, error)

func DeriveSender

func DeriveSender(dh []byte, sig []byte) (*ecdsa.PublicKey, error)

func DigestHash

func DigestHash(utx UnsignedTransaction) ([]byte, error)

func GetBalance

func GetBalance(db database.KeyValueReader, address common.Address) (uint64, error)

func GetLastAccepted

func GetLastAccepted(db database.KeyValueReader) (ids.ID, error)

func GetStakeBalance

func GetStakeBalance(db database.KeyValueReader, address common.Address) (uint64, error)

func GetValue

func GetValue(db database.KeyValueReader, key common.Hash) ([]byte, bool, error)

func HasKey

func HasKey(db database.KeyValueReader, key common.Hash) (bool, error)

DB

func HasLastAccepted

func HasLastAccepted(db database.Database) (bool, error)

func HasTransaction

func HasTransaction(db database.KeyValueReader, txID ids.ID) (bool, error)

func IsRegistered

func IsRegistered(d *DetailMeta, r *RegisterTx) bool

func IsRepeated

func IsRepeated(d *DetailMeta, r *RefreshTx) bool

func Marshal

func Marshal(source interface{}) ([]byte, error)

func ModifyBalance

func ModifyBalance(db database.KeyValueReaderWriter, address common.Address, add bool, change uint64) (uint64, error)

func ModifyStakeBalance

func ModifyStakeBalance(db database.KeyValueReaderWriter, address common.Address, add bool, change uint64) (uint64, error)

func NewActionsState

func NewActionsState(db database.Database) (*actionsState, error)

func NewDetailstate

func NewDetailstate(db database.Database) (*detailsState, error)

func NewPowState

func NewPowState(db database.Database) (*powState, error)

func NewRewardState

func NewRewardState(db database.Database) (*rewardState, error)

func NewStakerState

func NewStakerState(db database.Database) (*stakerState, error)

func NewSysParamsState

func NewSysParamsState(db database.Database, genesis *Genesis) (*sysParams, error)

func NewUserTypesState

func NewUserTypesState(db database.Database) (*userTypesState, error)

func NewUserstate

func NewUserstate(db database.Database, metrics prometheus.Registerer) (*usersState, error)

func NewYieldsState

func NewYieldsState(db database.Database) (*yieldsState, error)

func PrefixActionsKey

func PrefixActionsKey(actionID ids.ShortID) (k []byte)

func PrefixBalanceKey

func PrefixBalanceKey(address common.Address) (k []byte)

[balancePrefix] + [delimiter] + [address]

func PrefixBlockKey

func PrefixBlockKey(blockID ids.ID) (k []byte)

[blockPrefix] + [delimiter] + [blockID]

func PrefixDetailsKey

func PrefixDetailsKey(address common.Address) (k []byte)

func PrefixPowKey

func PrefixPowKey(powType byte, address common.Address) (k []byte)

func PrefixRewardKey

func PrefixRewardKey(address common.Address) (k []byte)

func PrefixStakeKey

func PrefixStakeKey(address common.Address) (k []byte)

[stakerPrefix] + [delimiter] + [address]

func PrefixStaker4Key

func PrefixStaker4Key(stakerType byte, address common.Address) (k []byte)

func PrefixSysParamsKey

func PrefixSysParamsKey() (k []byte)

func PrefixTxKey

func PrefixTxKey(txID ids.ID) (k []byte)

[txPrefix] + [delimiter] + [txID]

func PrefixTxValueKey

func PrefixTxValueKey(txID ids.ID) (k []byte)

[txValuePrefix] + [delimiter] + [txID]

func PrefixUserTypesKey

func PrefixUserTypesKey(id uint64) (k []byte)

func PrefixUsersKey

func PrefixUsersKey(address common.Address) (k []byte)

func PrefixYieldsKey

func PrefixYieldsKey() (k []byte)

func PutKey

func PutKey(db database.KeyValueWriter, key common.Hash, vmeta *ValueMeta) error

func RewardGlobalPrefix

func RewardGlobalPrefix() (k []byte)

func RouteStake

func RouteStake() uint64

func SelectRandomValue

func SelectRandomValue(db database.Database, seed []byte) []byte

func SerStake

func SerStake() uint64

func SetBalance

func SetBalance(db database.KeyValueWriter, address common.Address, bal uint64) error

func SetLastAccepted

func SetLastAccepted(db database.KeyValueWriter, block *StatelessBlock) error

func SetStakeBalance

func SetStakeBalance(db database.KeyValueWriter, address common.Address, bal uint64) error

func SetTransaction

func SetTransaction(db database.KeyValueWriter, tx *Transaction) error

func Sign

func Sign(dh []byte, priv *ecdsa.PrivateKey) ([]byte, error)

func Unmarshal

func Unmarshal(source []byte, destination interface{}) (uint16, error)

func ValidatorStake

func ValidatorStake() uint64

func ValueHash

func ValueHash(v []byte) common.Hash

func ValueHashString

func ValueHashString(v []byte) string

func ValueKey

func ValueKey(key common.Hash) (k []byte)

Assumes [key] does not contain delimiter [keyPrefix] + [delimiter] + [key]

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) Activity

func (c *AddUserTx) Activity() *Activity

func (*AddUserTx) Copy

func (c *AddUserTx) Copy() UnsignedTransaction

func (*AddUserTx) Execute

func (a *AddUserTx) Execute(t *TransactionContext) error

func (*AddUserTx) FeeUnits

func (c *AddUserTx) FeeUnits(g *Genesis) uint64

func (*AddUserTx) LoadUnits

func (c *AddUserTx) LoadUnits(g *Genesis) uint64

func (*AddUserTx) TypedData

func (c *AddUserTx) TypedData() *tdata.TypedData

type Airdrop

type Airdrop struct {
	// Address strings are hex-formatted common.Address
	Address common.Address `serialize:"true" json:"address"`
}

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) Copy

func (b *BaseTx) Copy() *BaseTx

func (*BaseTx) ExecuteBase

func (b *BaseTx) ExecuteBase(g *Genesis) error

func (*BaseTx) FeeUnits

func (b *BaseTx) FeeUnits(g *Genesis) uint64

func (*BaseTx) GetBlockID

func (b *BaseTx) GetBlockID() ids.ID

func (*BaseTx) GetMagic

func (b *BaseTx) GetMagic() uint64

func (*BaseTx) GetPrice

func (b *BaseTx) GetPrice() uint64

func (*BaseTx) LoadUnits

func (b *BaseTx) LoadUnits(g *Genesis) uint64

func (*BaseTx) SetBlockID

func (b *BaseTx) SetBlockID(bid ids.ID)

func (*BaseTx) SetMagic

func (b *BaseTx) SetMagic(magic uint64)

func (*BaseTx) SetPrice

func (b *BaseTx) SetPrice(price uint64)

type ClaimTx

type ClaimTx struct {
	*BaseTx      `serialize:"true" json:"baseTx"`
	RewardAmount uint64 `serialize:"true" json:"reward"`
	EndTime      uint64 `serialize:"true" json:"endTime"`
}

func (*ClaimTx) Activity

func (c *ClaimTx) Activity() *Activity

func (*ClaimTx) Copy

func (c *ClaimTx) Copy() UnsignedTransaction

func (*ClaimTx) Execute

func (c *ClaimTx) Execute(t *TransactionContext) error

func (*ClaimTx) FeeUnits

func (c *ClaimTx) FeeUnits(g *Genesis) uint64

func (*ClaimTx) LoadUnits

func (c *ClaimTx) LoadUnits(g *Genesis) uint64

func (*ClaimTx) TypedData

func (c *ClaimTx) TypedData() *tdata.TypedData

type Context

type Context struct {
	RecentBlockIDs  set.Set[ids.ID]
	RecentTxIDs     set.Set[ids.ID]
	RecentLoadUnits uint64

	Prices []uint64
	Costs  []uint64

	NextCost  uint64
	NextPrice uint64
}

type CustomAllocation

type CustomAllocation struct {
	// Address strings are hex-formatted common.Address
	Address common.Address `serialize:"true" json:"address"`
	Balance uint64         `serialize:"true" json:"balance"`
}

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) Load

func (g *Genesis) Load(db database.Database, airdropData []byte) error

func (*Genesis) StatefulBlock

func (g *Genesis) StatefulBlock() *StatefulBlock

func (*Genesis) Verify

func (g *Genesis) Verify() error

type GovernTx

type GovernTx struct {
	*BaseTx  `serialize:"true" json:"baseTx"`
	ActionID ids.ShortID `serialize:"true" json:"actionID"`
}

func (*GovernTx) Activity

func (g *GovernTx) Activity() *Activity

func (*GovernTx) Copy

func (g *GovernTx) Copy() UnsignedTransaction

func (*GovernTx) Execute

func (g *GovernTx) Execute(t *TransactionContext) error

func (*GovernTx) FeeUnits

func (g *GovernTx) FeeUnits(genesis *Genesis) uint64

func (*GovernTx) LoadUnits

func (g *GovernTx) LoadUnits(genesis *Genesis) uint64

func (*GovernTx) TypedData

func (g *GovernTx) TypedData() *tdata.TypedData

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 KeyValueMeta struct {
	Key       string     `serialize:"true" json:"key"`
	ValueMeta *ValueMeta `serialize:"true" json:"valueMeta"`
}

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) Add

func (m *MockMempool) Add(arg0 *Transaction) bool

Add mocks base method.

func (*MockMempool) EXPECT

func (m *MockMempool) EXPECT() *MockMempoolMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMempool) Len

func (m *MockMempool) Len() int

Len mocks base method.

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.

func (*MockMempool) Prune

func (m *MockMempool) Prune(arg0 set.Set[ids.ID])

Prune 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) Genesis

func (m *MockVM) Genesis() *Genesis

Genesis mocks base method.

func (*MockVM) GetStatelessBlock

func (m *MockVM) GetStatelessBlock(arg0 ids.ID) (*StatelessBlock, error)

GetStatelessBlock mocks base method.

func (*MockVM) IsBootstrapped

func (m *MockVM) IsBootstrapped() bool

IsBootstrapped mocks base method.

func (*MockVM) Mempool

func (m *MockVM) Mempool() Mempool

Mempool mocks base method.

func (*MockVM) Rejected

func (m *MockVM) Rejected(arg0 *StatelessBlock)

Rejected mocks base method.

func (*MockVM) SamaState

func (m *MockVM) SamaState() SamaState

SamaState mocks base method.

func (*MockVM) State

func (m *MockVM) State() database.Database

State 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 ProofMeta

type ProofMeta struct {
	Netflow    uint64         `serialize:"true" json:"netflow"`
	WorkTime   uint64         `serialize:"true" json:"workTime"`
	Miner      common.Address `serialize:"true" json:"miner"`
	TxID       ids.ID         `serialize:"true" json:"txId"`
	UpdateTime uint64         `serialize:"true" json:"updateTime"`
}

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) Activity

func (p *ProofTx) Activity() *Activity

func (*ProofTx) Copy

func (p *ProofTx) Copy() UnsignedTransaction

func (*ProofTx) Execute

func (p *ProofTx) Execute(t *TransactionContext) error

func (*ProofTx) FeeUnits

func (p *ProofTx) FeeUnits(g *Genesis) uint64

func (*ProofTx) LoadUnits

func (p *ProofTx) LoadUnits(g *Genesis) uint64

func (*ProofTx) TypedData

func (p *ProofTx) TypedData() *tdata.TypedData

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) Activity

func (r *RefreshTx) Activity() *Activity

func (*RefreshTx) Copy

func (r *RefreshTx) Copy() UnsignedTransaction

func (*RefreshTx) Execute

func (r *RefreshTx) Execute(t *TransactionContext) error

func (*RefreshTx) FeeUnits

func (r *RefreshTx) FeeUnits(g *Genesis) uint64

func (*RefreshTx) LoadUnits

func (r *RefreshTx) LoadUnits(g *Genesis) uint64

func (*RefreshTx) TypedData

func (r *RefreshTx) TypedData() *tdata.TypedData

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 RewardGlobal struct {
	LastOprTime uint64 `serialize:"true" json:"lastOprTime"`
	LastOprTXID ids.ID `serialize:"true" json:"lastOprTxId"`
}

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) Activity

func (s *SetTx) Activity() *Activity

func (*SetTx) Copy

func (s *SetTx) Copy() UnsignedTransaction

func (*SetTx) Execute

func (s *SetTx) Execute(t *TransactionContext) error

func (*SetTx) FeeUnits

func (s *SetTx) FeeUnits(g *Genesis) uint64

func (*SetTx) LoadUnits

func (s *SetTx) LoadUnits(g *Genesis) uint64

func (*SetTx) TypedData

func (s *SetTx) TypedData() *tdata.TypedData

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) Activity

func (s *StakeTx) Activity() *Activity

func (*StakeTx) Copy

func (s *StakeTx) Copy() UnsignedTransaction

func (*StakeTx) Execute

func (s *StakeTx) Execute(t *TransactionContext) error

func (*StakeTx) FeeUnits

func (s *StakeTx) FeeUnits(g *Genesis) uint64

func (*StakeTx) LoadUnits

func (s *StakeTx) LoadUnits(g *Genesis) uint64

func (*StakeTx) TypedData

func (s *StakeTx) TypedData() *tdata.TypedData

type StakerMeta

type StakerMeta struct {
	TxID        ids.ID         `serialize:"true" json:"txId"`
	StakerType  uint64         `serialize:"true" json:"stakerType"`
	StakeAmount uint64         `serialize:"true" json:"stakeAmount"`
	StakeTime   uint64         `serialize:"true" json:"stakeTime"`
	StakerAddr  common.Address `serialize:"true" json:"stakerAddr"`
}

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 NewBlock

func NewBlock(vm VM, parent snowman.Block, tmstp int64, context *Context) *StatelessBlock

func ParseBlock

func ParseBlock(
	source []byte,
	status choices.Status,
	vm VM,
) (*StatelessBlock, error)

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) Bytes

func (b *StatelessBlock) Bytes() []byte

implements "snowman.Block"

func (*StatelessBlock) Height

func (b *StatelessBlock) Height() uint64

implements "snowman.Block"

func (*StatelessBlock) ID

func (b *StatelessBlock) ID() ids.ID

implements "snowman.Block.choices.Decidable"

func (*StatelessBlock) Parent

func (b *StatelessBlock) Parent() ids.ID

implements "snowman.Block"

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"

func (*StatelessBlock) Verify

func (b *StatelessBlock) Verify(ctx context.Context) error

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 TransactionContext struct {
	Genesis   *Genesis
	Database  database.Database
	BlockTime uint64
	TxID      ids.ID
	Sender    common.Address
	// contains filtered or unexported fields
}

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) Activity

func (u *UnStakeTx) Activity() *Activity

func (*UnStakeTx) Copy

func (u *UnStakeTx) Copy() UnsignedTransaction

func (*UnStakeTx) Execute

func (u *UnStakeTx) Execute(t *TransactionContext) error

func (*UnStakeTx) FeeUnits

func (u *UnStakeTx) FeeUnits(g *Genesis) uint64

func (*UnStakeTx) LoadUnits

func (u *UnStakeTx) LoadUnits(g *Genesis) uint64

func (*UnStakeTx) TypedData

func (u *UnStakeTx) TypedData() *tdata.TypedData

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 UserType

type UserType struct {
	TypeName string `serialize:"true" json:"typeName"`
	TypeID   uint64 `serialize:"true" json:"typeID"`
	FeeUnits uint64 `serialize:"true" json:"fee"`
}

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

func GetValueMeta(db database.KeyValueReader, key common.Hash) (*ValueMeta, bool, error)

type VoteTx

type VoteTx struct {
	*BaseTx  `serialize:"true" json:"baseTx"`
	ActionID ids.ShortID `serialize:"true" json:"actionID"`
}

func (*VoteTx) Activity

func (v *VoteTx) Activity() *Activity

func (*VoteTx) Copy

func (v *VoteTx) Copy() UnsignedTransaction

func (*VoteTx) Execute

func (v *VoteTx) Execute(t *TransactionContext) error

func (*VoteTx) FeeUnits

func (v *VoteTx) FeeUnits(genesis *Genesis) uint64

func (*VoteTx) LoadUnits

func (v *VoteTx) LoadUnits(genesis *Genesis) uint64

func (*VoteTx) TypedData

func (v *VoteTx) TypedData() *tdata.TypedData

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

type YieldMeta

type YieldMeta struct {
	Total         uint64 `serialize:"true" json:"total"`
	Undistributed uint64 `serialize:"true" json:"undistributed"`
	LastOprTime   uint64 `serialize:"true" json:"lastOprTime"`
	LastOprTXID   ids.ID `serialize:"true" json:"lastOprTxId"`
}

type YieldsState

type YieldsState interface {
	GetChainYields() uint64
	ModifyYields(db database.Database, yield uint64, txID ids.ID, blkTime uint64) error
	ReloadYields(db database.Database) error
	CacheYieldsCommit() error
	CacheYieldsAbort() error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳