Documentation
¶
Index ¶
- Constants
- Variables
- func AuctionEncodeBytes(sb *AuctionBody) []byte
- func CalcRewardEpochRange(startEpoch, endEpoch uint64) (totalReward float64, totalUnrelease float64, epochRewards []float64, err error)
- func FloatToBigInt(val float64) *big.Int
- func GetAuctionInitialRelease() float64
- func GetAuctionReservedPrice() *big.Int
- func GetOpName(op uint32) string
- func SetAuctionGlobInst(inst *Auction)
- type Auction
- func (a *Auction) ClearAuction(cb *AuctionCB, state *state.State) (*big.Int, *big.Int, error)
- func (a *Auction) GetAuctionCB(state *state.State) (result *AuctionCB)
- func (a *Auction) GetSummaryList(state *state.State) (result *AuctionSummaryList)
- func (a *Auction) PrepareAuctionHandler() (...)
- func (a *Auction) SendMTRGToBidder(addr meter.Address, amount *big.Int, stateDB *statedb.StateDB)
- func (a *Auction) SetAuctionCB(auctionCB *AuctionCB, state *state.State)
- func (a *Auction) SetSummaryList(summaryList *AuctionSummaryList, state *state.State)
- func (a *Auction) Start() error
- func (a *Auction) TransferMTRToAuction(addr meter.Address, amount *big.Int, state *state.State) error
- func (a *Auction) TransferMTRToValidatorBenefit(amount *big.Int, state *state.State) error
- type AuctionBody
- func (ab *AuctionBody) CloseAuctionCB(senv *AuctionEnviroment, gas uint64) (ret []byte, leftOverGas uint64, err error)
- func (ab *AuctionBody) GetOpName(op uint32) string
- func (ab *AuctionBody) HandleAuctionTx(senv *AuctionEnviroment, gas uint64) (ret []byte, leftOverGas uint64, err error)
- func (ab *AuctionBody) StartAuctionCB(env *AuctionEnviroment, gas uint64) (ret []byte, leftOverGas uint64, err error)
- func (ab *AuctionBody) ToString() string
- type AuctionCB
- func (cb *AuctionCB) Add(c *AuctionTx) error
- func (cb *AuctionCB) AddAuctionTx(tx *AuctionTx)
- func (cb *AuctionCB) Count() int
- func (cb *AuctionCB) Exist(addr meter.Address) bool
- func (cb *AuctionCB) Get(addr meter.Address) *AuctionTx
- func (cb *AuctionCB) ID() (hash meter.Bytes32)
- func (cb *AuctionCB) IsActive() bool
- func (cb *AuctionCB) Remove(addr meter.Address) error
- func (cb *AuctionCB) ToList() []AuctionTx
- func (cb *AuctionCB) ToString() string
- type AuctionEnviroment
- type AuctionSummary
- type AuctionSummaryList
- func (a *AuctionSummaryList) Add(summary *AuctionSummary) error
- func (a *AuctionSummaryList) Count() int
- func (a *AuctionSummaryList) Get(id meter.Bytes32) *AuctionSummary
- func (a *AuctionSummaryList) Remove(id meter.Bytes32) error
- func (a *AuctionSummaryList) String() string
- func (a *AuctionSummaryList) ToList() []AuctionSummary
- func (a *AuctionSummaryList) ToString() string
- type AuctionTx
Constants ¶
View Source
const ( TOKEN_METER = byte(0) TOKEN_METER_GOV = byte(1) )
View Source
const ( OP_START = uint32(1) OP_STOP = uint32(2) OP_BID = uint32(3) )
View Source
const (
AUCTION_MAX_SUMMARIES = 1200
)
View Source
const (
N = 24 // history buffer size
)
Variables ¶
View Source
var ( // 0x74696f6e2d6163636f756e742d61646472657373 AuctionAccountAddr = meter.BytesToAddress([]byte("auction-account-address")) SummaryListKey = meter.Blake2b([]byte("summary-list-key")) AuctionCBKey = meter.Blake2b([]byte("auction-active-cb-key")) )
the global variables in auction
Functions ¶
func AuctionEncodeBytes ¶
func AuctionEncodeBytes(sb *AuctionBody) []byte
func CalcRewardEpochRange ¶
func CalcRewardEpochRange(startEpoch, endEpoch uint64) (totalReward float64, totalUnrelease float64, epochRewards []float64, err error)
released MTRG for a speciefic range
func FloatToBigInt ¶
func GetAuctionInitialRelease ¶
func GetAuctionInitialRelease() float64
func GetAuctionReservedPrice ¶
func SetAuctionGlobInst ¶
func SetAuctionGlobInst(inst *Auction)
Types ¶
type Auction ¶
type Auction struct {
// contains filtered or unexported fields
}
Candidate indicates the structure of a candidate
var (
AuctionGlobInst *Auction
)
func GetAuctionGlobInst ¶
func GetAuctionGlobInst() *Auction
func (*Auction) ClearAuction ¶
============================================== when auction is over
func (*Auction) GetAuctionCB ¶
Candidate List
func (*Auction) GetSummaryList ¶
func (a *Auction) GetSummaryList(state *state.State) (result *AuctionSummaryList)
summary List
func (*Auction) PrepareAuctionHandler ¶
func (*Auction) SendMTRGToBidder ¶
func (*Auction) SetAuctionCB ¶
func (*Auction) SetSummaryList ¶
func (a *Auction) SetSummaryList(summaryList *AuctionSummaryList, state *state.State)
type AuctionBody ¶
type AuctionBody struct {
Opcode uint32
Version uint32
Option uint32
StartHeight uint64
StartEpoch uint64
EndHeight uint64
EndEpoch uint64
AuctionID meter.Bytes32
Bidder meter.Address
Amount *big.Int
ReserveAmount *big.Int
Token byte // meter or meter gov
Timestamp uint64 // timestamp
Nonce uint64 // nonce
}
Candidate indicates the structure of a candidate
func AuctionDecodeFromBytes ¶
func AuctionDecodeFromBytes(bytes []byte) (*AuctionBody, error)
func (*AuctionBody) CloseAuctionCB ¶
func (ab *AuctionBody) CloseAuctionCB(senv *AuctionEnviroment, gas uint64) (ret []byte, leftOverGas uint64, err error)
func (*AuctionBody) GetOpName ¶
func (ab *AuctionBody) GetOpName(op uint32) string
func (*AuctionBody) HandleAuctionTx ¶
func (ab *AuctionBody) HandleAuctionTx(senv *AuctionEnviroment, gas uint64) (ret []byte, leftOverGas uint64, err error)
func (*AuctionBody) StartAuctionCB ¶
func (ab *AuctionBody) StartAuctionCB(env *AuctionEnviroment, gas uint64) (ret []byte, leftOverGas uint64, err error)
func (*AuctionBody) ToString ¶
func (ab *AuctionBody) ToString() string
type AuctionCB ¶
type AuctionCB struct {
AuctionID meter.Bytes32
StartHeight uint64
StartEpoch uint64
EndHeight uint64
EndEpoch uint64
RlsdMTRG *big.Int //released mtrg
RsvdMTRG *big.Int // reserved mtrg
RsvdPrice *big.Int
CreateTime uint64
//changed fields after auction start
RcvdMTR *big.Int
AuctionTxs []*AuctionTx
}
auctionTx indicates the structure of a auctionTx
func (*AuctionCB) AddAuctionTx ¶
type AuctionEnviroment ¶
type AuctionEnviroment struct {
// contains filtered or unexported fields
}
func NewAuctionEnviroment ¶
func NewAuctionEnviroment(auction *Auction, state *state.State, txCtx *xenv.TransactionContext, to *meter.Address) *AuctionEnviroment
func (*AuctionEnviroment) GetAuction ¶
func (env *AuctionEnviroment) GetAuction() *Auction
func (*AuctionEnviroment) GetState ¶
func (env *AuctionEnviroment) GetState() *state.State
func (*AuctionEnviroment) GetToAddr ¶
func (env *AuctionEnviroment) GetToAddr() *meter.Address
func (*AuctionEnviroment) GetTxCtx ¶
func (env *AuctionEnviroment) GetTxCtx() *xenv.TransactionContext
type AuctionSummary ¶
type AuctionSummary struct {
AuctionID meter.Bytes32
StartHeight uint64
StartEpoch uint64
EndHeight uint64
EndEpoch uint64
RlsdMTRG *big.Int
RsvdMTRG *big.Int
RsvdPrice *big.Int
CreateTime uint64
RcvdMTR *big.Int
ActualPrice *big.Int
LeftoverMTRG *big.Int
}
func (*AuctionSummary) ToString ¶
func (a *AuctionSummary) ToString() string
type AuctionSummaryList ¶
type AuctionSummaryList struct {
Summaries []*AuctionSummary
}
func GetAuctionSummaryList ¶
func GetAuctionSummaryList() (*AuctionSummaryList, error)
api routine interface
func NewAuctionSummaryList ¶
func NewAuctionSummaryList(summaries []*AuctionSummary) *AuctionSummaryList
func (*AuctionSummaryList) Add ¶
func (a *AuctionSummaryList) Add(summary *AuctionSummary) error
func (*AuctionSummaryList) Count ¶
func (a *AuctionSummaryList) Count() int
func (*AuctionSummaryList) Get ¶
func (a *AuctionSummaryList) Get(id meter.Bytes32) *AuctionSummary
func (*AuctionSummaryList) Remove ¶
func (a *AuctionSummaryList) Remove(id meter.Bytes32) error
unsupport at this time
func (*AuctionSummaryList) String ¶
func (a *AuctionSummaryList) String() string
func (*AuctionSummaryList) ToList ¶
func (a *AuctionSummaryList) ToList() []AuctionSummary
func (*AuctionSummaryList) ToString ¶
func (a *AuctionSummaryList) ToString() string
Click to show internal directories.
Click to hide internal directories.