Documentation
¶
Index ¶
- Constants
- func AccountIsExist(mail string) (bool, error)
- func CreateEvidences(chainID string, es types.EvidenceList) (err error)
- func CreateGenesis(chainId string, genesisTime time.Time, data string) error
- func CreateNetworkOrUpdate(chainID string, n *Network) error
- func DeleteNodeByName(name string) error
- func DropDatabase(name string) error
- func GetNodeEngine(name string) (*xorm.Engine, error)
- func InitDb(cfg *config.DBConfig) (err error)
- func NewTestEngine(cfg *config.DBConfig) (*testEngine, error)
- func UpdateFee(chainID, tx, fee string, gasWanted, gasUsed int64) error
- type Account
- func (a *Account) AfterSet(colName string, _ xorm.Cell)
- func (a *Account) Apps() ([]*App, error)
- func (a *Account) BeforeInsert()
- func (a *Account) BeforeUpdate()
- func (a *Account) CheckPassword(pwd string) bool
- func (a *Account) CreateApp(name string) (*App, error)
- func (a *Account) CreateSession(loginType int, expire time.Duration) (string, error)
- func (a *Account) DeleteAppByID(id int64) error
- func (a *Account) DeleteSession() error
- func (a *Account) Insert() error
- func (a *Account) UpdatePassword(pwd string) error
- func (a *Account) UpdateProfile(opt *AccountOption) error
- type AccountOption
- type Agent
- type App
- type AtmIpRecord
- type AtmRecord
- type Block
- type BlockOption
- type BlockValidator
- type BlockValidatorOption
- type ConsensusState
- type Engine
- type Evidence
- type Fee
- type Genesis
- type LoginStatus
- type Missing
- type Network
- type NetworkOption
- type Node
- type NodeRoute
- type Peer
- type PeerOption
- type Proposal
- type QmoonStatus
- type TmBlock
- type Tx
- type TxOption
- type TxTransfer
- type TxTransferOption
- type Validator
- type VerifyCode
Constants ¶
View Source
const ( NetworkStatusValid = 1 NetworkStatusInvalid = 2 )
View Source
const DefaultFeeTx = "default"
View Source
const VerifyCodeDuration = time.Minute
View Source
const VerifyCodeExpired = time.Minute * 15
Variables ¶
This section is empty.
Functions ¶
func AccountIsExist ¶
func CreateEvidences ¶
func CreateEvidences(chainID string, es types.EvidenceList) (err error)
func CreateNetworkOrUpdate ¶
func DeleteNodeByName ¶
func NewTestEngine ¶
Types ¶
type Account ¶
type Account struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Mail string `xorm:"unique"`
Name string `xorm:"VARCHAR(64)"`
Avatar string `xorm:"TEXT"`
Description string `xorm:"TEXT"`
Status int `xorm:"INTEGER"`
Password string `xorm:"VARCHAR(128)"`
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func Accounts ¶
func Accounts(opt *AccountOption) ([]*Account, error)
func CreateAccount ¶
func RetrieveAccountByID ¶
func RetrieveAccountByMail ¶
func (*Account) BeforeInsert ¶
func (a *Account) BeforeInsert()
func (*Account) BeforeUpdate ¶
func (a *Account) BeforeUpdate()
func (*Account) CheckPassword ¶
func (*Account) CreateSession ¶
func (*Account) DeleteAppByID ¶
func (*Account) DeleteSession ¶
func (*Account) UpdatePassword ¶
func (*Account) UpdateProfile ¶
func (a *Account) UpdateProfile(opt *AccountOption) error
type AccountOption ¶
type Agent ¶
type Agent struct {
Id int64 `xorm:"pk autoincr BIGINT"`
NodeType string `xorm:"TEXT"`
BaseUrl string `xorm:"TEXT"`
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func AgentsByNodeType ¶
func CreateAgent ¶
func (*Agent) BeforeInsert ¶
func (n *Agent) BeforeInsert()
func (*Agent) BeforeUpdate ¶
func (n *Agent) BeforeUpdate()
type App ¶
type App struct {
Id int64 `xorm:"pk autoincr BIGINT" json:"id"`
Name string `xorm:"VARCHAR(64)" json:"name"`
SecretKey string `xorm:"unique TEXT" json:"secretKey"`
Status int `xorm:"INTEGER" json:"-"`
AccountId int64 `xorm:"index BIGINT" json:"accountId"`
Version int `xorm:"version" json:"-"`
DeletedAt time.Time `xorm:"deleted" json:"-"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func AppBySecretKey ¶
func AppsByAccount ¶
func (*App) BeforeInsert ¶
func (a *App) BeforeInsert()
func (*App) BeforeUpdate ¶
func (a *App) BeforeUpdate()
type AtmIpRecord ¶
type AtmIpRecord struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Chainid string `xorm:"-"`
Ip string `xorm:"unique(atm_ip_record_ip_created_at_unix) TEXT"`
Amount int
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64 `xorm:"unique(atm_ip_record_ip_created_at_unix)"`
}
func (*AtmIpRecord) BeforeInsert ¶
func (air *AtmIpRecord) BeforeInsert()
func (*AtmIpRecord) BeforeUpdate ¶
func (air *AtmIpRecord) BeforeUpdate()
func (*AtmIpRecord) Insert ¶
func (air *AtmIpRecord) Insert(chainID string) error
func (*AtmIpRecord) Update ¶
func (air *AtmIpRecord) Update(chainID string) error
type AtmRecord ¶
type AtmRecord struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Address string `xorm:"unique(atm_record_address_idx)"`
Coin string `xorm:"TEXT"`
Amount string `xorm:"TEXT"`
Height int64 `xorm:"BIGINT"`
Hash string `xorm:"TEXT"`
Createat time.Time `xorm:"unique(atm_record_address_idx)"`
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func (*AtmRecord) BeforeInsert ¶
func (ar *AtmRecord) BeforeInsert()
func (*AtmRecord) BeforeUpdate ¶
func (ar *AtmRecord) BeforeUpdate()
type Block ¶
type Block struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ChainId string `xorm:"-"`
Height int64 `xorm:"unique(blocks_height_idx) BIGINT"`
NumTxs int64 `xorm:"BIGINT"`
TotalTxs int64 `xorm:"BIGINT"`
DataHash string `xorm:"TEXT"`
ValidatorsNum int64 `xorm:"BIGINT"`
ValidatorsTotal int64 `xorm:"BIGINT"`
ValidatorsHash string `xorm:"TEXT"`
ProposerAddress string `xorm:"TEXT"`
Time time.Time `xorm:"-"`
TimeUnix int64
}
func (*Block) BeforeInsert ¶
func (b *Block) BeforeInsert()
func (*Block) BeforeUpdate ¶
func (b *Block) BeforeUpdate()
type BlockOption ¶
type BlockValidator ¶
type BlockValidator struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ChainId string `xorm:"-"`
Height int64 `xorm:"index(block_validators_height_idx) BIGINT"`
ValidatorAddress string `xorm:"index TEXT"`
ValidatorIndex int64 `xorm:"BIGINT"`
Type int64 `xorm:"BIGINT"`
Round int64 `xorm:"BIGINT"`
Signature string `xorm:"TEXT"`
VotingPower int64 `xorm:"BIGINT"`
Accum int64 `xorm:"BIGINT"`
Time time.Time `xorm:"-"`
TimeUnix int64
}
func BlockValidators ¶
func BlockValidators(chainID string, opt *BlockValidatorOption) ([]*BlockValidator, error)
func (*BlockValidator) BeforeInsert ¶
func (bv *BlockValidator) BeforeInsert()
func (*BlockValidator) BeforeUpdate ¶
func (bv *BlockValidator) BeforeUpdate()
func (*BlockValidator) Insert ¶
func (bv *BlockValidator) Insert(chainID string) error
type BlockValidatorOption ¶
type ConsensusState ¶
type ConsensusState struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ChainId string `xorm:"-"`
Height string `xorm:"TEXT"`
Round string `xorm:"TEXT"`
Step string `xorm:"TEXT"`
PrevotesNum int64 `xorm:"BIGINT"`
PrevotesValue string `xorm:"TEXT"`
PrecommitsNum int64 `xorm:"BIGINT"`
PrecommitsValue string `xorm:"TEXT"`
StartTime string `xorm:"TEXT"`
}
func RetrieveConsensusState ¶
func RetrieveConsensusState(chainID string) (*ConsensusState, error)
func (*ConsensusState) Insert ¶
func (cs *ConsensusState) Insert(chainID string) error
func (*ConsensusState) Update ¶
func (cs *ConsensusState) Update(chainID string) error
type Engine ¶
type Engine interface {
Delete(interface{}) (int64, error)
Exec(string, ...interface{}) (sql.Result, error)
Find(interface{}, ...interface{}) error
Get(interface{}) (bool, error)
ID(interface{}) *xorm.Session
In(string, ...interface{}) *xorm.Session
Insert(...interface{}) (int64, error)
InsertOne(interface{}) (int64, error)
Iterate(interface{}, xorm.IterFunc) error
Sql(string, ...interface{}) *xorm.Session
Table(interface{}) *xorm.Session
Where(interface{}, ...interface{}) *xorm.Session
}
Engine represents a XORM engine or session.
type Evidence ¶
type Evidence struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Height int64 `xorm:"BIGINT"`
ValidatorAddress string `xorm:"TEXT"`
Hash string `xorm:"TEXT"`
Data string `xorm:"TEXT"`
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func RetrieveEvidences ¶
func (*Evidence) BeforeInsert ¶
func (n *Evidence) BeforeInsert()
func (*Evidence) BeforeUpdate ¶
func (n *Evidence) BeforeUpdate()
type Fee ¶
type Fee struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Tx string `xorm:"unique(fee_tx_idx) TEXT"`
GasWanted int64 `xorm:"BIGINT"`
GasUsed int64 `xorm:"BIGINT"`
Fee string `xorm:"TEXT"`
ChainID string `xorm:"-"`
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func RetrieveFeeByTx ¶
func (*Fee) BeforeInsert ¶
func (n *Fee) BeforeInsert()
func (*Fee) BeforeUpdate ¶
func (n *Fee) BeforeUpdate()
type Genesis ¶
type Genesis struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ChainId string `xorm:"-"`
GenesisTime time.Time `xorm:"-"`
GenesisTimeUnix int64
Data string `xorm:"TEXT"`
}
func RetrieveGenesis ¶
func (*Genesis) BeforeInsert ¶
func (g *Genesis) BeforeInsert()
func (*Genesis) BeforeUpdate ¶
func (g *Genesis) BeforeUpdate()
type LoginStatus ¶
type LoginStatus struct {
Id int64 `xorm:"pk autoincr BIGINT"`
AccountId int64 `xorm:"unique BIGINT"`
LoginType int `xorm:"default 0 SMALLINT"`
Token string `xorm:"unique VARCHAR(64)"`
ExpiredAtUnix int64
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func LoginStatusByAccountID ¶
func LoginStatusByAccountID(id int64) (*LoginStatus, error)
func LoginStatusByLoginStatusByToken ¶
func LoginStatusByLoginStatusByToken(token string) (*LoginStatus, error)
func (*LoginStatus) Account ¶
func (ls *LoginStatus) Account() (*Account, error)
func (*LoginStatus) BeforeInsert ¶
func (ls *LoginStatus) BeforeInsert()
func (*LoginStatus) BeforeUpdate ¶
func (ls *LoginStatus) BeforeUpdate()
func (*LoginStatus) Insert ¶
func (ls *LoginStatus) Insert(chainID string) error
type Missing ¶
type Missing struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ValidatorAddress string `xorm:"TEXT"`
Height int64 `xorm:"BIGINT"`
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func RetrieveMissings ¶
func (*Missing) BeforeInsert ¶
func (n *Missing) BeforeInsert()
func (*Missing) BeforeUpdate ¶
func (n *Missing) BeforeUpdate()
type Network ¶
type Network struct {
ID int64 `json:"id"`
Remote string `json:"remote"`
Delay int64 `json:"delay"`
Status int `json:"status"` // 1: 有效 2: 无效
LastTestAt time.Time `xorm:"-"`
LastTestAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func (*Network) BeforeInsert ¶
func (n *Network) BeforeInsert()
func (*Network) BeforeUpdate ¶
func (n *Network) BeforeUpdate()
func (*Network) InsertOrUpdate ¶
type NetworkOption ¶
type Node ¶
type Node struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Name string `xorm:"unique VARCHAR(128)"`
BaseUrl string `xorm:"TEXT"`
SecretKey string `xorm:"TEXT"`
ChainId string `xorm:"TEXT"`
NodeType string `xorm:"TEXT"`
NodeVersion string `xorm:"TEXT"`
Sort int
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func CreateNode ¶
func RetrieveNodeByName ¶
func (*Node) BeforeInsert ¶
func (n *Node) BeforeInsert()
func (*Node) BeforeUpdate ¶
func (n *Node) BeforeUpdate()
type Peer ¶
type Peer struct {
ID int64 `json:"id"`
ChainID string `json:"chain_id"`
Moniker string `json:"moniker"`
PeerID string `xorm:"unique" json:"peer_id"`
ListenAddr string `json:"listen_addr"`
Network string `json:"network"`
Version string `json:"version"`
Channels string `json:"channels"`
SendStart time.Time `xorm:"-" json:"send_start"`
SendStartUnix int64
RecvStart time.Time `xorm:"-" json:"recv_start"`
RecvStartUnix int64
}
func (*Peer) BeforeInsert ¶
func (p *Peer) BeforeInsert()
func (*Peer) BeforeUpdate ¶
func (p *Peer) BeforeUpdate()
type PeerOption ¶
type PeerOption struct {
Offset, Limit int
}
type Proposal ¶ added in v0.0.6
type Proposal struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ProposalID int64 `xorm:"BIGINT"`
Title string `xorm:"unique(title_tx_idx) TEXT"`
Description string `xorm:"TEXT"`
Type string `xorm:"TEXT"`
Status string `xorm:"TEXT"`
SubmitTime time.Time `xorm:"-"`
VotingStartTime time.Time `xorm:"-"`
TotalDeposit int64 `xorm:"BIGINT"`
ChainID string `xorm:"-"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func (*Proposal) BeforeInsert ¶ added in v0.0.6
func (n *Proposal) BeforeInsert()
func (*Proposal) BeforeUpdate ¶ added in v0.0.6
func (n *Proposal) BeforeUpdate()
func (*Proposal) UpdateStatus ¶ added in v0.0.6
type QmoonStatus ¶
type QmoonStatus struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Key string `xorm:"unique VARCHAR(64)"`
Value string `xorm:"TEXT"`
Version int `xorm:"version"`
UpdatedAt time.Time `xorm:"-"`
UpdatedAtUnix int64
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func RetrieveQmoonStatusByKey ¶
func RetrieveQmoonStatusByKey(key string) (*QmoonStatus, error)
func (*QmoonStatus) BeforeInsert ¶
func (qs *QmoonStatus) BeforeInsert()
func (*QmoonStatus) BeforeUpdate ¶
func (qs *QmoonStatus) BeforeUpdate()
func (*QmoonStatus) Insert ¶
func (qs *QmoonStatus) Insert() error
func (*QmoonStatus) Update ¶
func (qs *QmoonStatus) Update() error
type TmBlock ¶
type Tx ¶
type Tx struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ChainId string `xorm:"-"`
Height int64 `xorm:"index(txs_height_idx) unique(txs_height_index_idx) BIGINT"`
TxType string `xorm:"TEXT"`
Index int64 `xorm:"unique(txs_height_index_idx) BIGINT"`
Hash string
Maxgas int64 `xorm:"BIGINT"`
GasWanted int64
Fee string
GasUsed int64
QcpFrom string `xorm:"TEXT"`
QcpTo string `xorm:"TEXT"`
QcpSequence int64 `xorm:"BIGINT"`
QcpTxindex int64 `xorm:"BIGINT"`
QcpIsresult bool `xorm:"BOOL"`
TxStatus int `xorm:"default 0 INTEGER"`
OriginTx string `xorm:"TEXT"`
JsonTx string `xorm:"TEXT"`
Log string `xorm:"TEXT"`
Time time.Time `xorm:"-"`
TimeUnix int64
}
func (*Tx) BeforeInsert ¶
func (t *Tx) BeforeInsert()
func (*Tx) BeforeUpdate ¶
func (t *Tx) BeforeUpdate()
type TxTransfer ¶
type TxTransfer struct {
Id int64 `xorm:"pk autoincr BIGINT"`
ChainId string `xorm:"-"`
Height int64 `xorm:"BIGINT"`
Hash string `xorm:"TEXT"`
Address string `xorm:"index TEXT"`
Coin string `xorm:"TEXT"`
Amount string `xorm:"TEXT"`
TxStatus int `xorm:"default 0 INTEGER"`
IsMulti bool `xorm:"default false BOOL"`
MultiData string `xorm:"TEXT"`
Type int `xorm:"SMALLINT"`
Time time.Time `xorm:"-"`
TimeUnix int64
}
func TxTransfers ¶
func TxTransfers(chainID string, opt *TxTransferOption) ([]*TxTransfer, error)
func (*TxTransfer) BeforeInsert ¶
func (tt *TxTransfer) BeforeInsert()
func (*TxTransfer) BeforeUpdate ¶
func (tt *TxTransfer) BeforeUpdate()
func (*TxTransfer) Insert ¶
func (tt *TxTransfer) Insert(chainID string) error
type TxTransferOption ¶
type Validator ¶
type Validator struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Name string `xorm:"TEXT"`
Details string `xorm:"TEXT"`
Identity string `xorm:"TEXT"`
Logo string
Website string `xorm:"TEXT"`
Owner string `xorm:"TEXT"`
ChainId string `xorm:"-"`
Address string `xorm:"unique TEXT"`
PubKeyType string `xorm:"TEXT"`
PubKeyValue string `xorm:"TEXT"`
Commission string `xorm:"TEXT"`
VotingPower int64 `xorm:"BIGINT"`
Accum int64 `xorm:"BIGINT"`
FirstBlockHeight int64 `xorm:"BIGINT"`
FirstBlockTime time.Time `xorm:"-"`
FirstBlockTimeUnix int64
Status int `xorm:"INTEGER"`
InactiveCode int `xorm:"INTEGER"`
InactiveTime time.Time `xorm:"-"`
InactiveTimeUnix int64
InactiveHeight int64 `xorm:"BIGINT"`
BondHeight int64 `xorm:"BIGINT"`
PrecommitNum int64
}
func ValidatorByAddress ¶
func Validators ¶
func (*Validator) BeforeInsert ¶
func (val *Validator) BeforeInsert()
func (*Validator) BeforeUpdate ¶
func (val *Validator) BeforeUpdate()
func (*Validator) UpdateStatus ¶
type VerifyCode ¶
type VerifyCode struct {
Id int64 `xorm:"pk autoincr BIGINT"`
Email string `xorm:"unique TEXT"`
Code string `xorm:"TEXT"`
Version int `xorm:"version"`
CreatedAt time.Time `xorm:"-"`
CreatedAtUnix int64
}
func CreateVerifyCode ¶
func CreateVerifyCode(email, code string) (*VerifyCode, error)
func VerifyCodeByEmail ¶
func VerifyCodeByEmail(email string) (*VerifyCode, error)
func (*VerifyCode) BeforeInsert ¶
func (vc *VerifyCode) BeforeInsert()
func (*VerifyCode) BeforeUpdate ¶
func (vc *VerifyCode) BeforeUpdate()
func (*VerifyCode) Delete ¶
func (vc *VerifyCode) Delete() error
func (*VerifyCode) Insert ¶
func (vc *VerifyCode) Insert() error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.