Documentation ¶
Overview ¶
Package database is a generated GoMock package.
Index ¶
- Constants
- Variables
- func EmptyGas() *common.Fixed
- func LoadBlockhead(path string) (*block.BlockHead, error)
- func LoadTxInfo(path string) (*tx.Tx, error)
- func Marshal(in interface{}, extras ...string) (string, error)
- func MustMarshal(in interface{}, extra ...string) string
- func MustUnmarshal(o string) interface{}
- func MustUnmarshalWithExtra(o string) (interface{}, string)
- func NewBatchVisitor(lruDB *LRU) (*Visitor, Mapper)
- func Unmarshal(o string) interface{}
- func UnmarshalWithExtra(o string) (interface{}, string)
- type Access
- type AccountRAMInfo
- type AccountVoteInfo
- type BasicHandler
- type ContractHandler
- type DelaytxHandler
- type FreezeItem
- type FreezeItemFixed
- type GasHandler
- func (g *GasHandler) ChangeTGas(name string, delta *common.Fixed)
- func (g *GasHandler) GasLimit(name string) *common.Fixed
- func (g *GasHandler) GasPledge(name string, pledger string) *common.Fixed
- func (g *GasHandler) GasPledgeTotal(name string) *common.Fixed
- func (g *GasHandler) GasStock(name string) *common.Fixed
- func (g *GasHandler) GasUpdateTime(name string) int64
- func (g *GasHandler) PGasAtTime(name string, t int64) (result *common.Fixed)
- func (g *GasHandler) PledgerInfo(name string) []PledgerInfo
- func (g *GasHandler) TGas(name string) *common.Fixed
- func (g *GasHandler) TotalGasAtTime(name string, t int64) (result *common.Fixed)
- type IMultiValue
- type LRU
- type MapHandler
- type Mapper
- type MockIMultiValue
- func (m *MockIMultiValue) Commit()
- func (m *MockIMultiValue) Del(arg0, arg1 string) error
- func (m *MockIMultiValue) EXPECT() *MockIMultiValueMockRecorder
- func (m *MockIMultiValue) Get(arg0, arg1 string) (string, error)
- func (m *MockIMultiValue) Has(arg0, arg1 string) (bool, error)
- func (m *MockIMultiValue) Keys(arg0, arg1 string) ([]string, error)
- func (m *MockIMultiValue) Put(arg0, arg1, arg2 string) error
- func (m *MockIMultiValue) Rollback()
- type MockIMultiValueMockRecorder
- func (mr *MockIMultiValueMockRecorder) Commit() *gomock.Call
- func (mr *MockIMultiValueMockRecorder) Del(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockIMultiValueMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockIMultiValueMockRecorder) Has(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockIMultiValueMockRecorder) Keys(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockIMultiValueMockRecorder) Put(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockIMultiValueMockRecorder) Rollback() *gomock.Call
- type Mode
- type PledgerInfo
- type ProducerVoteInfo
- type RAMHandler
- func (r *RAMHandler) BuyPrice() float64
- func (r *RAMHandler) ChangeUsedRAMInfo(acc string, delta int64)
- func (r *RAMHandler) GetAccountRAMInfo(acc string) *AccountRAMInfo
- func (r *RAMHandler) LeftRAM() int64
- func (r *RAMHandler) SellPrice() float64
- func (r *RAMHandler) TotalRAM() int64
- func (r *RAMHandler) UsedRAM() int64
- type Record
- type RollbackHandler
- type SerializedJSON
- type SimpleDB
- func (d *SimpleDB) AddSystem(path string)
- func (d *SimpleDB) Commit()
- func (d *SimpleDB) Del(table string, key string) error
- func (d *SimpleDB) Get(table string, key string) (string, error)
- func (d *SimpleDB) Has(table string, key string) (bool, error)
- func (d *SimpleDB) Keys(table string, prefix string) ([]string, error)
- func (d *SimpleDB) Load(path string) error
- func (d *SimpleDB) Put(table string, key string, value string) error
- func (d *SimpleDB) Rollback()
- func (d *SimpleDB) Save(path string) error
- type Token721Handler
- func (m *Token721Handler) Token721Balance(tokenName, acc string) int64
- func (m *Token721Handler) Token721IDList(tokenName, acc string) []string
- func (m *Token721Handler) Token721Metadata(tokenName, tokenID string) (string, error)
- func (m *Token721Handler) Token721Owner(tokenName, tokenID string) (string, error)
- type TokenHandler
- func (m *TokenHandler) AllFreezedTokenBalance(tokenName, acc string) []FreezeItem
- func (m *TokenHandler) AllFreezedTokenBalanceFixed(tokenName, acc string) []FreezeItemFixed
- func (m *TokenHandler) Decimal(tokenName string) int
- func (m *TokenHandler) FreezedTokenBalance(tokenName, acc string) int64
- func (m *TokenHandler) FreezedTokenBalanceFixed(tokenName, acc string) *common.Fixed
- func (m *TokenHandler) SetTokenBalance(tokenName, acc string, amount int64)
- func (m *TokenHandler) SetTokenBalanceFixed(tokenName, acc string, amountStr string)
- func (m *TokenHandler) TokenBalance(tokenName, acc string) int64
- func (m *TokenHandler) TokenBalanceFixed(tokenName, acc string) *common.Fixed
- type Visitor
- type VoteHandler
- type Watcher
- type WriteCache
Constants ¶
const ( // GasPledgeTotalKey : how many EMPOW is pledged GasPledgeTotalKey = "gt" // GasLimitKey : how much gas can be generated max per EMPOW GasLimitKey = "gl" // GasUpdateTimeKey : when the gas state is refreshed last time, for internal use GasUpdateTimeKey = "gu" // GasStockKey : how much gas is there when last time refreshed GasStockKey = "gs" // GasPledgeKey : i pledge how much coins for others GasPledgeKey = "gp" // TransferableGasKey : TransferableGasKey = "tg" // TransferableGasQuotaKey : TransferableGasQuotaKey = "tq" )
const ( IntPrefix = "i" StringPrefix = "s" NilPrefix = "n" BoolPrefix = "b" JSONPrefix = "j" MapHolderPrefix = "@" FixPointPrefix = "f" )
const prefixs
const ApplicationSeparator = "@"
ApplicationSeparator separator of value
const BasicPrefix = "b-"
BasicPrefix prefix of basic types
const ContractPrefix = "c-"
ContractPrefix ...
const EMPOWRatio int64 = 100000000
EMPOWRatio ...
const GasContractName = "gas.empow"
GasContractName name of basic token contract
const (
GasDecimal = 2
)
decimals of gas
const GasFulfillSeconds int64 = 2 * 24 * 3600
GasFulfillSeconds it takes 2 days to fulfill the gas buffer.
const MapPrefix = "m-"
MapPrefix prefix of map key
const RAMContractName = "ram.empow"
RAMContractName name of basic token contract
const Separator = "-"
Separator separator of map key
const (
// StateTable name
StateTable = "state"
)
const Token721ContractName = "token721.empow"
Token721ContractName name of basic token contract
const TokenContractName = "token.empow"
TokenContractName name of basic token contract
const VoteContractName = "vote.empow"
VoteContractName name of common vote contract
const VoteProducerContractName = "vote_producer.empow"
VoteProducerContractName name of vote producer contract
Variables ¶
var GasImmediateReward = &common.Fixed{Value: 100000 * 100, Decimal: 2}
GasImmediateReward immediate reward per EMPOW
var GasIncreaseRate = GasLimit.Sub(GasImmediateReward).Div(GasFulfillSeconds)
GasIncreaseRate gas increase per EMPOW per second
var GasLimit = &common.Fixed{Value: 300000 * 100, Decimal: 2}
GasLimit gas limit per EMPOW
var GasMinPledgeOfUser = &common.Fixed{Value: 10 * EMPOWRatio, Decimal: 8}
GasMinPledgeOfUser Each user must pledge a minimum amount of EMPOW
var GasMinPledgePerAction = &common.Fixed{Value: 1 * EMPOWRatio, Decimal: 8}
GasMinPledgePerAction One must (un)pledge more than 1 EMPOW
Functions ¶
func LoadBlockhead ¶
LoadBlockhead load block info as block.BlockHead from json file
func LoadTxInfo ¶
LoadTxInfo load tx info as tx.Tx from json file
func MustMarshal ¶
MustMarshal marshal go types to value string, panic on error
func MustUnmarshal ¶
func MustUnmarshal(o string) interface{}
MustUnmarshal unmarshal value string to go types, panic on error
func MustUnmarshalWithExtra ¶
MustUnmarshalWithExtra unmarshal value string to go types, panic on error
func NewBatchVisitor ¶
NewBatchVisitor get visitor with mapper
func UnmarshalWithExtra ¶
UnmarshalWithExtra unmarshal value string to go types
Types ¶
type AccountRAMInfo ¶
type AccountRAMInfo struct { // Used ... Used int64 // Available ... Available int64 // Total ... Total int64 }
AccountRAMInfo ...
type AccountVoteInfo ¶
AccountVoteInfo ...
type BasicHandler ¶
type BasicHandler struct {
// contains filtered or unexported fields
}
BasicHandler handler of basic type
func (*BasicHandler) Del ¶
func (m *BasicHandler) Del(key string)
Del del key, if key is nil do nothing
type ContractHandler ¶
type ContractHandler struct {
// contains filtered or unexported fields
}
ContractHandler ...
func (*ContractHandler) Contract ¶
func (m *ContractHandler) Contract(key string) (c *contract.Contract)
Contract get contract by key
func (*ContractHandler) DelContract ¶
func (m *ContractHandler) DelContract(key string)
DelContract delete contract, if contract not exist, do nothing
func (*ContractHandler) HasContract ¶
func (m *ContractHandler) HasContract(key string) bool
HasContract determine if contract existed
func (*ContractHandler) SetContract ¶
func (m *ContractHandler) SetContract(contract *contract.Contract)
SetContract set contract to storage, will not do check
type DelaytxHandler ¶
type DelaytxHandler struct {
// contains filtered or unexported fields
}
DelaytxHandler handler of delay tx
func (*DelaytxHandler) DelDelaytx ¶
func (m *DelaytxHandler) DelDelaytx(txHash string)
DelDelaytx deletes the delaytx hash.
func (*DelaytxHandler) GetDelaytx ¶
func (m *DelaytxHandler) GetDelaytx(txHash string) (string, string)
GetDelaytx gets the delay tx's publisher and deferTxHash.
func (*DelaytxHandler) HasDelaytx ¶
func (m *DelaytxHandler) HasDelaytx(txHash string) bool
HasDelaytx checks whether the delaytx exists.
func (*DelaytxHandler) StoreDelaytx ¶
func (m *DelaytxHandler) StoreDelaytx(txHash, publisher, deferTxHash string)
StoreDelaytx stores delaytx hash.
type FreezeItem ¶
FreezeItem represents freezed balance, will unfreeze after Ftime
type FreezeItemFixed ¶
FreezeItemFixed ...
type GasHandler ¶
type GasHandler struct { BasicHandler MapHandler }
GasHandler easy to get balance of token.empow
func (*GasHandler) ChangeTGas ¶
func (g *GasHandler) ChangeTGas(name string, delta *common.Fixed)
ChangeTGas ...
func (*GasHandler) GasPledge ¶
func (g *GasHandler) GasPledge(name string, pledger string) *common.Fixed
GasPledge ...
func (*GasHandler) GasPledgeTotal ¶
func (g *GasHandler) GasPledgeTotal(name string) *common.Fixed
GasPledgeTotal ...
func (*GasHandler) GasStock ¶
func (g *GasHandler) GasStock(name string) *common.Fixed
GasStock `gasStock` means the gas amount at last update time.
func (*GasHandler) GasUpdateTime ¶
func (g *GasHandler) GasUpdateTime(name string) int64
GasUpdateTime ...
func (*GasHandler) PGasAtTime ¶
func (g *GasHandler) PGasAtTime(name string, t int64) (result *common.Fixed)
PGasAtTime return pledge gas at given time. It is min(limit, last_updated_gas + time_since_last_updated * increase_speed)
func (*GasHandler) PledgerInfo ¶
func (g *GasHandler) PledgerInfo(name string) []PledgerInfo
PledgerInfo get I pledged how much coins for others
func (*GasHandler) TotalGasAtTime ¶
func (g *GasHandler) TotalGasAtTime(name string, t int64) (result *common.Fixed)
TotalGasAtTime return total gas at given time.. It is pgas + tgas
type IMultiValue ¶
type IMultiValue interface { Get(table string, key string) (string, error) Put(table string, key string, value string) error Del(table string, key string) error Has(table string, key string) (bool, error) }
IMultiValue mvcc database interface
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU lru cache
func NewBatchVisitorRoot ¶
func NewBatchVisitorRoot(cacheLength int, cb IMultiValue, rules *version.Rules) *LRU
NewBatchVisitorRoot get LRU to next step
type MapHandler ¶
type MapHandler struct {
// contains filtered or unexported fields
}
MapHandler handler of map
func (*MapHandler) MDel ¶
func (m *MapHandler) MDel(key, field string)
MDel delete field of map o(1)
func (*MapHandler) MGet ¶
func (m *MapHandler) MGet(key, field string) (value string)
MGet get value from storage o(1)
func (*MapHandler) MHas ¶
func (m *MapHandler) MHas(key, field string) bool
MHas if has map and field
func (*MapHandler) MKeys ¶
func (m *MapHandler) MKeys(key string) (fields []string)
MKeys list fields of map o(1)
func (*MapHandler) MPut ¶
func (m *MapHandler) MPut(key, field, value string)
MPut put value in kfv storage o(1)
type MockIMultiValue ¶
type MockIMultiValue struct {
// contains filtered or unexported fields
}
MockIMultiValue is a mock of IMultiValue interface
func NewMockIMultiValue ¶
func NewMockIMultiValue(ctrl *gomock.Controller) *MockIMultiValue
NewMockIMultiValue creates a new mock instance
func (*MockIMultiValue) Del ¶
func (m *MockIMultiValue) Del(arg0, arg1 string) error
Del mocks base method
func (*MockIMultiValue) EXPECT ¶
func (m *MockIMultiValue) EXPECT() *MockIMultiValueMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockIMultiValue) Get ¶
func (m *MockIMultiValue) Get(arg0, arg1 string) (string, error)
Get mocks base method
func (*MockIMultiValue) Has ¶
func (m *MockIMultiValue) Has(arg0, arg1 string) (bool, error)
Has mocks base method
func (*MockIMultiValue) Keys ¶
func (m *MockIMultiValue) Keys(arg0, arg1 string) ([]string, error)
Keys mocks base method
func (*MockIMultiValue) Put ¶
func (m *MockIMultiValue) Put(arg0, arg1, arg2 string) error
Put mocks base method
type MockIMultiValueMockRecorder ¶
type MockIMultiValueMockRecorder struct {
// contains filtered or unexported fields
}
MockIMultiValueMockRecorder is the mock recorder for MockIMultiValue
func (*MockIMultiValueMockRecorder) Commit ¶
func (mr *MockIMultiValueMockRecorder) Commit() *gomock.Call
Commit indicates an expected call of Commit
func (*MockIMultiValueMockRecorder) Del ¶
func (mr *MockIMultiValueMockRecorder) Del(arg0, arg1 interface{}) *gomock.Call
Del indicates an expected call of Del
func (*MockIMultiValueMockRecorder) Get ¶
func (mr *MockIMultiValueMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call
Get indicates an expected call of Get
func (*MockIMultiValueMockRecorder) Has ¶
func (mr *MockIMultiValueMockRecorder) Has(arg0, arg1 interface{}) *gomock.Call
Has indicates an expected call of Has
func (*MockIMultiValueMockRecorder) Keys ¶
func (mr *MockIMultiValueMockRecorder) Keys(arg0, arg1 interface{}) *gomock.Call
Keys indicates an expected call of Keys
func (*MockIMultiValueMockRecorder) Put ¶
func (mr *MockIMultiValueMockRecorder) Put(arg0, arg1, arg2 interface{}) *gomock.Call
Put indicates an expected call of Put
func (*MockIMultiValueMockRecorder) Rollback ¶
func (mr *MockIMultiValueMockRecorder) Rollback() *gomock.Call
Rollback indicates an expected call of Rollback
type ProducerVoteInfo ¶
type ProducerVoteInfo struct { Pubkey string Loc string URL string NetID string IsProducer bool Status string Online bool }
ProducerVoteInfo ...
type RAMHandler ¶
type RAMHandler struct {
BasicHandler
}
RAMHandler easy to get balance of token.empow
func (*RAMHandler) ChangeUsedRAMInfo ¶
func (r *RAMHandler) ChangeUsedRAMInfo(acc string, delta int64)
ChangeUsedRAMInfo ...
func (*RAMHandler) GetAccountRAMInfo ¶
func (r *RAMHandler) GetAccountRAMInfo(acc string) *AccountRAMInfo
GetAccountRAMInfo ...
type RollbackHandler ¶
type RollbackHandler struct {
// contains filtered or unexported fields
}
RollbackHandler rollback delegate
func (*RollbackHandler) Rollback ¶
func (m *RollbackHandler) Rollback()
Rollback rollback to newest MVCC version
type SimpleDB ¶
type SimpleDB struct {
// contains filtered or unexported fields
}
SimpleDB implements simple database interface
func NewDatabase ¶
func NewDatabase() *SimpleDB
NewDatabase returns a SimpleDB with empty data and system contract
func NewDatabaseFromPath ¶
NewDatabaseFromPath returns a SimpleDB with data loaded from json file
type Token721Handler ¶
type Token721Handler struct {
// contains filtered or unexported fields
}
Token721Handler easy to get balance of token.empow
func (*Token721Handler) Token721Balance ¶
func (m *Token721Handler) Token721Balance(tokenName, acc string) int64
Token721Balance get token balance of acc
func (*Token721Handler) Token721IDList ¶
func (m *Token721Handler) Token721IDList(tokenName, acc string) []string
Token721IDList get token balance of acc
func (*Token721Handler) Token721Metadata ¶
func (m *Token721Handler) Token721Metadata(tokenName, tokenID string) (string, error)
Token721Metadata get token balance of acc
func (*Token721Handler) Token721Owner ¶
func (m *Token721Handler) Token721Owner(tokenName, tokenID string) (string, error)
Token721Owner get token owner of tokenID
type TokenHandler ¶
type TokenHandler struct {
// contains filtered or unexported fields
}
TokenHandler easy to get balance of token.empow
func (*TokenHandler) AllFreezedTokenBalance ¶
func (m *TokenHandler) AllFreezedTokenBalance(tokenName, acc string) []FreezeItem
AllFreezedTokenBalance get freezed token balance of acc
func (*TokenHandler) AllFreezedTokenBalanceFixed ¶
func (m *TokenHandler) AllFreezedTokenBalanceFixed(tokenName, acc string) []FreezeItemFixed
AllFreezedTokenBalanceFixed get freezed token balance of acc
func (*TokenHandler) Decimal ¶
func (m *TokenHandler) Decimal(tokenName string) int
Decimal get decimal in token info
func (*TokenHandler) FreezedTokenBalance ¶
func (m *TokenHandler) FreezedTokenBalance(tokenName, acc string) int64
FreezedTokenBalance get freezed token balance of acc
func (*TokenHandler) FreezedTokenBalanceFixed ¶
func (m *TokenHandler) FreezedTokenBalanceFixed(tokenName, acc string) *common.Fixed
FreezedTokenBalanceFixed get token balance of acc
func (*TokenHandler) SetTokenBalance ¶
func (m *TokenHandler) SetTokenBalance(tokenName, acc string, amount int64)
SetTokenBalance set token balance of acc, used for test
func (*TokenHandler) SetTokenBalanceFixed ¶
func (m *TokenHandler) SetTokenBalanceFixed(tokenName, acc string, amountStr string)
SetTokenBalanceFixed set token balance of acc, used for test
func (*TokenHandler) TokenBalance ¶
func (m *TokenHandler) TokenBalance(tokenName, acc string) int64
TokenBalance get token balance of acc
func (*TokenHandler) TokenBalanceFixed ¶
func (m *TokenHandler) TokenBalanceFixed(tokenName, acc string) *common.Fixed
TokenBalanceFixed get token balance of acc
type Visitor ¶
type Visitor struct { BasicHandler MapHandler ContractHandler TokenHandler Token721Handler RollbackHandler DelaytxHandler GasHandler RAMHandler VoteHandler }
Visitor combine of every handler, to be api of database
func NewVisitor ¶
func NewVisitor(cacheLength int, cb IMultiValue, rules *version.Rules) *Visitor
NewVisitor get a visitor of a DB, with cache length determined
type VoteHandler ¶
type VoteHandler struct { BasicHandler MapHandler }
VoteHandler easy to get info of vote.empow and vote_producer.empow
func (*VoteHandler) GetAccountVoteInfo ¶
func (v *VoteHandler) GetAccountVoteInfo(account string) []*AccountVoteInfo
GetAccountVoteInfo ...
func (*VoteHandler) GetProducerVoteInfo ¶
func (v *VoteHandler) GetProducerVoteInfo(account string) (*ProducerVoteInfo, error)
GetProducerVoteInfo ...
func (*VoteHandler) GetProducerVotes ¶
func (v *VoteHandler) GetProducerVotes(account string) (*common.Fixed, error)
GetProducerVotes ...
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher of db access
type WriteCache ¶
type WriteCache struct {
// contains filtered or unexported fields
}
WriteCache ...