Documentation ¶
Index ¶
- Constants
- Variables
- func AuctionEncodeBytes(sb *AuctionBody) []byte
- func GetOpName(op uint32) string
- func SetAuctionGlobInst(inst *Auction)
- type Auction
- func (a *Auction) ClearAuction(cb *AuctionCB, state *state.State, env *AuctionEnv) (*big.Int, *big.Int, []*DistMtrg, 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, env *AuctionEnv)
- 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) TransferAutobidMTRToAuction(addr meter.Address, amount *big.Int, state *state.State, env *AuctionEnv) error
- func (a *Auction) TransferMTRToAuction(addr meter.Address, amount *big.Int, state *state.State, env *AuctionEnv) error
- func (a *Auction) TransferMTRToValidatorBenefit(amount *big.Int, state *state.State, env *AuctionEnv) error
- type AuctionBody
- func (ab *AuctionBody) CloseAuctionCB(env *AuctionEnv, gas uint64) (leftOverGas uint64, err error)
- func (ab *AuctionBody) GetOpName(op uint32) string
- func (ab *AuctionBody) HandleAuctionTx(env *AuctionEnv, gas uint64) (leftOverGas uint64, err error)
- func (ab *AuctionBody) StartAuctionCB(env *AuctionEnv, gas uint64) (leftOverGas uint64, err error)
- func (sb *AuctionBody) String() string
- func (ab *AuctionBody) ToString() string
- func (sb *AuctionBody) UniteHash() (hash meter.Bytes32)
- type AuctionCB
- func (cb *AuctionCB) Add(tx *AuctionTx)
- func (cb *AuctionCB) AddAuctionTx(tx *AuctionTx) error
- func (cb *AuctionCB) Count() int
- func (cb *AuctionCB) Exist(id meter.Bytes32) bool
- func (cb *AuctionCB) Get(id meter.Bytes32) *AuctionTx
- func (cb *AuctionCB) ID() (hash meter.Bytes32)
- func (cb *AuctionCB) IsActive() bool
- func (cb *AuctionCB) Remove(id meter.Bytes32)
- func (cb *AuctionCB) RemoveAuctionTx(tx *AuctionTx) error
- func (cb *AuctionCB) ToString() string
- func (cb *AuctionCB) ToTxList() []*AuctionTx
- type AuctionEnv
- 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) Last() *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
- type DistMtrg
Constants ¶
View Source
const ( OP_START = uint32(1) OP_STOP = uint32(2) OP_BID = uint32(3) USER_BID = uint32(0) AUTO_BID = uint32(1) )
View Source
const (
AUCTION_MAX_SUMMARIES = 32
)
Variables ¶
View Source
var ( // normal min amount is 10 mtr, autobid is 0.1 mtr MinimumBidAmount = new(big.Int).Mul(big.NewInt(10), big.NewInt(1e18)) AutobidMinAmount = big.NewInt(1e17) )
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 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 ¶
func (a *Auction) ClearAuction(cb *AuctionCB, state *state.State, env *AuctionEnv) (*big.Int, *big.Int, []*DistMtrg, error)
////////////////////// called 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)
func (*Auction) TransferAutobidMTRToAuction ¶ added in v1.2.0
func (a *Auction) TransferAutobidMTRToAuction(addr meter.Address, amount *big.Int, state *state.State, env *AuctionEnv) error
==================== account openation=========================== from meter.ValidatorBenefitAddr ==> AuctionAccountAddr
func (*Auction) TransferMTRToAuction ¶
func (a *Auction) TransferMTRToAuction(addr meter.Address, amount *big.Int, state *state.State, env *AuctionEnv) error
from addr == > AuctionAccountAddr
func (*Auction) TransferMTRToValidatorBenefit ¶
func (a *Auction) TransferMTRToValidatorBenefit(amount *big.Int, state *state.State, env *AuctionEnv) error
form AuctionAccountAddr ==> meter.ValidatorBenefitAddr
type AuctionBody ¶
type AuctionBody struct { Opcode uint32 Version uint32 Option uint32 StartHeight uint64 StartEpoch uint64 EndHeight uint64 EndEpoch uint64 Sequence 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(env *AuctionEnv, gas uint64) (leftOverGas uint64, err error)
func (*AuctionBody) GetOpName ¶
func (ab *AuctionBody) GetOpName(op uint32) string
func (*AuctionBody) HandleAuctionTx ¶
func (ab *AuctionBody) HandleAuctionTx(env *AuctionEnv, gas uint64) (leftOverGas uint64, err error)
func (*AuctionBody) StartAuctionCB ¶
func (ab *AuctionBody) StartAuctionCB(env *AuctionEnv, gas uint64) (leftOverGas uint64, err error)
func (*AuctionBody) String ¶ added in v1.2.0
func (sb *AuctionBody) String() string
func (*AuctionBody) ToString ¶
func (ab *AuctionBody) ToString() string
func (*AuctionBody) UniteHash ¶ added in v1.2.0
func (sb *AuctionBody) UniteHash() (hash meter.Bytes32)
type AuctionCB ¶
type AuctionCB struct { AuctionID meter.Bytes32 StartHeight uint64 StartEpoch uint64 EndHeight uint64 EndEpoch uint64 Sequence 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 ¶
func (*AuctionCB) RemoveAuctionTx ¶ added in v1.2.0
Actually Auction do not allow to cancel, so this func should not be called
type AuctionEnv ¶ added in v1.2.0
func NewAuctionEnv ¶ added in v1.2.0
func NewAuctionEnv(auction *Auction, state *state.State, txCtx *xenv.TransactionContext, to *meter.Address) *AuctionEnv
func (*AuctionEnv) GetAuction ¶ added in v1.2.0
func (env *AuctionEnv) GetAuction() *Auction
type AuctionSummary ¶
type AuctionSummary struct { AuctionID meter.Bytes32 StartHeight uint64 StartEpoch uint64 EndHeight uint64 EndEpoch uint64 Sequence uint64 RlsdMTRG *big.Int RsvdMTRG *big.Int RsvdPrice *big.Int CreateTime uint64 RcvdMTR *big.Int ActualPrice *big.Int LeftoverMTRG *big.Int AuctionTxs []*AuctionTx DistMTRG []*DistMtrg }
func (*AuctionSummary) ToString ¶
func (a *AuctionSummary) ToString() string
type AuctionSummaryList ¶
type AuctionSummaryList struct {
Summaries []*AuctionSummary
}
func GetAuctionSummaryList ¶
func GetAuctionSummaryList() (*AuctionSummaryList, error)
func GetAuctionSummaryListByHeader ¶ added in v1.2.0
func GetAuctionSummaryListByHeader(header *block.Header) (*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) Last ¶ added in v1.2.0
func (a *AuctionSummaryList) Last() *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.