Documentation
¶
Overview ¶
Package database is a generated GoMock package.
Index ¶
- Constants
- func LoadBlockhead(path string) (*block.BlockHead, error)
- func LoadTxInfo(path string) (*tx.Tx, error)
- func Marshal(in interface{}) (string, error)
- func MustMarshal(in interface{}) string
- func MustUnmarshal(o string) interface{}
- func Unmarshal(o string) interface{}
- type BalanceHandler
- type BasicHandler
- type CoinHandler
- type ContractHandler
- type IMultiValue
- type LRU
- type MapHandler
- 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 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 Visitor
Constants ¶
const ( IntPrefix = "i" StringPrefix = "s" NilPrefix = "n" BoolPrefix = "b" JSONPrefix = "j" MapHolderPrefix = "@" )
const prefixs
const BasicPrefix = "b-"
BasicPrefix prefix of basic types
const (
// CoinPrefix ...
CoinPrefix = "o-"
)
const ContractPrefix = "c-"
ContractPrefix ...
const (
// IOSTPrefix prefix of iost
IOSTPrefix = "i-"
)
const MapPrefix = "m-"
MapPrefix prefix of map key
const Separator = "-"
Separator separator of map key
const (
// StateTable name
StateTable = "state"
)
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 ¶
func MustMarshal(in interface{}) string
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
Types ¶
type BalanceHandler ¶
type BalanceHandler struct {
// contains filtered or unexported fields
}
BalanceHandler handler of balace storage
func (*BalanceHandler) Balance ¶
func (m *BalanceHandler) Balance(name string) int64
Balance get balance to id
func (*BalanceHandler) Servi ¶
func (m *BalanceHandler) Servi(name string) int64
Servi get servi of name, return 0 if not exists
func (*BalanceHandler) SetBalance ¶
func (m *BalanceHandler) SetBalance(to string, delta int64)
SetBalance set balance to id
func (*BalanceHandler) SetServi ¶
func (m *BalanceHandler) SetServi(to string, delta int64)
SetServi add delta to servi of to
func (*BalanceHandler) TotalServi ¶
func (m *BalanceHandler) TotalServi() int64
TotalServi get total servi of name, return 0 if not exists
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 CoinHandler ¶
type CoinHandler struct {
// contains filtered or unexported fields
}
CoinHandler handler of coin
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 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) Keys(table string, prefix string) ([]string, error) Commit() Rollback() }
IMultiValue mvcc database interface
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU lru cache
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 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 Visitor ¶
type Visitor struct { BasicHandler MapHandler ContractHandler BalanceHandler CoinHandler RollbackHandler }
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