Documentation ¶
Overview ¶
Package database is a generated GoMock package.
Index ¶
- Constants
- 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 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) GasRate(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 RAMHandler
- 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 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 Watcher
- type WriteCache
Constants ¶
const ( // GasRateKey : how much gas is generated per IOST per second GasRateKey = "gr" // GasLimitKey : how much gas can be generated max per IOST GasLimitKey = "gl" // GasUpdateTimeKey : when the gas state is refreshed last time, for internal use GasUpdateTimeKey = "gt" // GasStockKey : how much gas is there when last time refreshed GasStockKey = "gs" // GasPledgeKey : who pledge how much coins for me GasPledgeKey = "gp" // TransferableGasKey : TransferableGasKey = "tg" )
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 GasContractName = "gas.iost"
GasContractName name of basic token contract
const (
GasDecimal = 2
)
decimals of gas
const MapPrefix = "m-"
MapPrefix prefix of map key
const RAMContractName = "ram.iost"
RAMContractName name of basic token contract
const Separator = "-"
Separator separator of map key
const (
// StateTable name
StateTable = "state"
)
const TokenContractName = "token.iost"
TokenContractName name of basic token contract
Variables ¶
This section is empty.
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 ¶ added in v1.1.0
MustUnmarshalWithExtra unmarshal value string to go types, panic on error
func NewBatchVisitor ¶ added in v1.1.0
NewBatchVisitor get visitor with mapper
func UnmarshalWithExtra ¶ added in v1.1.0
UnmarshalWithExtra unmarshal value string to go types
Types ¶
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 ¶ added in v1.1.0
type DelaytxHandler struct {
// contains filtered or unexported fields
}
DelaytxHandler handler of delay tx
func (*DelaytxHandler) DelDelaytx ¶ added in v1.1.0
func (m *DelaytxHandler) DelDelaytx(txHash string)
DelDelaytx deletes the delaytx hash.
func (*DelaytxHandler) HasDelaytx ¶ added in v1.1.0
func (m *DelaytxHandler) HasDelaytx(txHash string) bool
HasDelaytx checks whether the delaytx exists.
func (*DelaytxHandler) StoreDelaytx ¶ added in v1.1.0
func (m *DelaytxHandler) StoreDelaytx(txHash string)
StoreDelaytx stores delaytx hash.
type FreezeItem ¶ added in v1.1.0
FreezeItem represents freezed balance, will unfreeze after Ftime
type FreezeItemFixed ¶ added in v1.1.0
FreezeItemFixed ...
type GasHandler ¶ added in v1.1.0
type GasHandler struct { BasicHandler MapHandler }
GasHandler easy to get balance of token.iost
func (*GasHandler) ChangeTGas ¶ added in v1.1.0
func (g *GasHandler) ChangeTGas(name string, delta *common.Fixed)
ChangeTGas ...
func (*GasHandler) GasLimit ¶ added in v1.1.0
func (g *GasHandler) GasLimit(name string) *common.Fixed
GasLimit ...
func (*GasHandler) GasPledge ¶ added in v1.1.0
func (g *GasHandler) GasPledge(name string, pledger string) *common.Fixed
GasPledge ...
func (*GasHandler) GasRate ¶ added in v1.1.0
func (g *GasHandler) GasRate(name string) *common.Fixed
GasRate ...
func (*GasHandler) GasStock ¶ added in v1.1.0
func (g *GasHandler) GasStock(name string) *common.Fixed
GasStock `gasStock` means the gas amount at last update time.
func (*GasHandler) GasUpdateTime ¶ added in v1.1.0
func (g *GasHandler) GasUpdateTime(name string) int64
GasUpdateTime ...
func (*GasHandler) PGasAtTime ¶ added in v1.1.0
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 ¶ added in v1.1.0
func (g *GasHandler) PledgerInfo(name string) []PledgerInfo
PledgerInfo get who pledged how much coins for me
func (*GasHandler) TGas ¶ added in v1.1.0
func (g *GasHandler) TGas(name string) *common.Fixed
TGas ...
func (*GasHandler) TotalGasAtTime ¶ added in v1.1.0
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) Commit() Rollback() }
IMultiValue mvcc database interface
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU lru cache
func NewBatchVisitorRoot ¶ added in v1.1.0
func NewBatchVisitorRoot(cacheLength int, cb IMultiValue) *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 PledgerInfo ¶ added in v1.1.0
PledgerInfo ...
type RAMHandler ¶ added in v1.1.0
type RAMHandler struct {
// contains filtered or unexported fields
}
RAMHandler easy to get balance of token.iost
func (*RAMHandler) SellPrice ¶ added in v1.1.0
func (r *RAMHandler) SellPrice() float64
SellPrice ...
type Record ¶ added in v1.1.0
type Record struct {
// contains filtered or unexported fields
}
Record of one access
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 TokenHandler ¶ added in v1.1.0
type TokenHandler struct {
// contains filtered or unexported fields
}
TokenHandler easy to get balance of token.iost
func (*TokenHandler) AllFreezedTokenBalance ¶ added in v1.1.0
func (m *TokenHandler) AllFreezedTokenBalance(tokenName, acc string) []FreezeItem
AllFreezedTokenBalance get freezed token balance of acc
func (*TokenHandler) AllFreezedTokenBalanceFixed ¶ added in v1.1.0
func (m *TokenHandler) AllFreezedTokenBalanceFixed(tokenName, acc string) []FreezeItemFixed
AllFreezedTokenBalanceFixed get freezed token balance of acc
func (*TokenHandler) Decimal ¶ added in v1.1.0
func (m *TokenHandler) Decimal(tokenName string) int
Decimal get decimal in token info
func (*TokenHandler) FreezedTokenBalance ¶ added in v1.1.0
func (m *TokenHandler) FreezedTokenBalance(tokenName, acc string) int64
FreezedTokenBalance get freezed token balance of acc
func (*TokenHandler) FreezedTokenBalanceFixed ¶ added in v1.1.0
func (m *TokenHandler) FreezedTokenBalanceFixed(tokenName, acc string) *common.Fixed
FreezedTokenBalanceFixed get token balance of acc
func (*TokenHandler) SetTokenBalance ¶ added in v1.1.0
func (m *TokenHandler) SetTokenBalance(tokenName, acc string, amount int64)
SetTokenBalance set token balance of acc, used for test
func (*TokenHandler) SetTokenBalanceFixed ¶ added in v1.1.0
func (m *TokenHandler) SetTokenBalanceFixed(tokenName, acc string, amountStr string)
SetTokenBalanceFixed set token balance of acc, used for test
func (*TokenHandler) TokenBalance ¶ added in v1.1.0
func (m *TokenHandler) TokenBalance(tokenName, acc string) int64
TokenBalance get token balance of acc
func (*TokenHandler) TokenBalanceFixed ¶ added in v1.1.0
func (m *TokenHandler) TokenBalanceFixed(tokenName, acc string) *common.Fixed
TokenBalanceFixed get token balance of acc
type Visitor ¶
type Visitor struct { BasicHandler MapHandler ContractHandler TokenHandler RollbackHandler DelaytxHandler GasHandler RAMHandler }
Visitor combine of every handler, to be api of database
func NewVisitor ¶
func NewVisitor(cacheLength int, cb IMultiValue) *Visitor
NewVisitor get a visitor of a DB, with cache length determined
type Watcher ¶ added in v1.1.0
type Watcher struct {
// contains filtered or unexported fields
}
Watcher of db access
type WriteCache ¶ added in v1.1.0
type WriteCache struct {
// contains filtered or unexported fields
}
WriteCache ...
func (*WriteCache) Get ¶ added in v1.1.0
func (w *WriteCache) Get(key string) (value string)
Get ...