Documentation
¶
Index ¶
- Variables
- func NewUpdateBatch() protocol.StoreBatcher
- type BlockGetter
- type ConcurrentMap
- func (m ConcurrentMap) Clear()
- func (m ConcurrentMap) Count() int
- func (m ConcurrentMap) Get(key string) (interface{}, bool)
- func (m ConcurrentMap) GetShard(key string) *ConcurrentMapShared
- func (m ConcurrentMap) Has(key string) bool
- func (m ConcurrentMap) IsEmpty() bool
- func (m ConcurrentMap) Items() map[string]interface{}
- func (m ConcurrentMap) Iter() <-chan Tuple
- func (m ConcurrentMap) IterBuffered() <-chan Tuple
- func (m ConcurrentMap) IterCb(fn IterCb)
- func (m ConcurrentMap) Keys() []string
- func (m ConcurrentMap) MSet(data map[string]interface{})
- func (m ConcurrentMap) MarshalJSON() ([]byte, error)
- func (m ConcurrentMap) Pop(key string) (v interface{}, exists bool)
- func (m ConcurrentMap) Remove(key string)
- func (m ConcurrentMap) RemoveCb(key string, cb RemoveCb) bool
- func (m ConcurrentMap) Set(key string, value interface{})
- func (m ConcurrentMap) SetIfAbsent(key string, value interface{}) bool
- func (m ConcurrentMap) Upsert(key string, value interface{}, cb UpsertCb) (res interface{})
- type ConcurrentMapShared
- type ConnectionPoolDBHandle
- type EngineType
- type HistoryIteratorImpl
- type IterCb
- type RemoveCb
- type SavePoint
- type SqlVerifyPass
- type StandardSqlVerify
- type Tuple
- type TxHistoryIteratorImpl
- type UpdateBatch
- func (batch *UpdateBatch) Delete(key []byte)
- func (batch *UpdateBatch) Get(key []byte) ([]byte, error)
- func (batch *UpdateBatch) Has(key []byte) bool
- func (batch *UpdateBatch) KVs() map[string][]byte
- func (batch *UpdateBatch) Keys() []string
- func (batch *UpdateBatch) Len() int
- func (batch *UpdateBatch) Merge(u protocol.StoreBatcher)
- func (batch *UpdateBatch) Put(key []byte, value []byte)
- func (batch *UpdateBatch) ReSet()
- func (batch *UpdateBatch) SplitBatch(batchCnt uint64) []protocol.StoreBatcher
- type UpsertCb
Constants ¶
This section is empty.
Variables ¶
var SHARD_COUNT = 32
Functions ¶
func NewUpdateBatch ¶
func NewUpdateBatch() protocol.StoreBatcher
NewUpdateBatch constructs an instance of a Batch
Types ¶
type BlockGetter ¶ added in v2.2.0
type BlockGetter interface {
GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)
}
type ConcurrentMap ¶ added in v2.2.0
type ConcurrentMap []*ConcurrentMapShared
A "thread" safe map of type string:Anything. To avoid lock bottlenecks this map is dived to several (SHARD_COUNT) map shards.
func (ConcurrentMap) Clear ¶ added in v2.2.0
func (m ConcurrentMap) Clear()
Clear removes all items from map.
func (ConcurrentMap) Count ¶ added in v2.2.0
func (m ConcurrentMap) Count() int
Count returns the number of elements within the map.
func (ConcurrentMap) Get ¶ added in v2.2.0
func (m ConcurrentMap) Get(key string) (interface{}, bool)
Get retrieves an element from map under given key.
func (ConcurrentMap) GetShard ¶ added in v2.2.0
func (m ConcurrentMap) GetShard(key string) *ConcurrentMapShared
GetShard returns shard under given key
func (ConcurrentMap) Has ¶ added in v2.2.0
func (m ConcurrentMap) Has(key string) bool
Looks up an item under specified key
func (ConcurrentMap) IsEmpty ¶ added in v2.2.0
func (m ConcurrentMap) IsEmpty() bool
IsEmpty checks if map is empty.
func (ConcurrentMap) Items ¶ added in v2.2.0
func (m ConcurrentMap) Items() map[string]interface{}
Items returns all items as map[string]interface{}
func (ConcurrentMap) Iter ¶ added in v2.2.0
func (m ConcurrentMap) Iter() <-chan Tuple
Iter returns an iterator which could be used in a for range loop. Deprecated: using IterBuffered() will get a better performance
func (ConcurrentMap) IterBuffered ¶ added in v2.2.0
func (m ConcurrentMap) IterBuffered() <-chan Tuple
IterBuffered returns a buffered iterator which could be used in a for range loop.
func (ConcurrentMap) IterCb ¶ added in v2.2.0
func (m ConcurrentMap) IterCb(fn IterCb)
Callback based iterator, cheapest way to read all elements in a map.
func (ConcurrentMap) Keys ¶ added in v2.2.0
func (m ConcurrentMap) Keys() []string
Keys returns all keys as []string
func (ConcurrentMap) MSet ¶ added in v2.2.0
func (m ConcurrentMap) MSet(data map[string]interface{})
func (ConcurrentMap) MarshalJSON ¶ added in v2.2.0
func (m ConcurrentMap) MarshalJSON() ([]byte, error)
Reviles ConcurrentMap "private" variables to json marshal.
func (ConcurrentMap) Pop ¶ added in v2.2.0
func (m ConcurrentMap) Pop(key string) (v interface{}, exists bool)
Pop removes an element from the map and returns it
func (ConcurrentMap) Remove ¶ added in v2.2.0
func (m ConcurrentMap) Remove(key string)
Remove removes an element from the map.
func (ConcurrentMap) RemoveCb ¶ added in v2.2.0
func (m ConcurrentMap) RemoveCb(key string, cb RemoveCb) bool
RemoveCb locks the shard containing the key, retrieves its current value and calls the callback with those params If callback returns true and element exists, it will remove it from the map Returns the value returned by the callback (even if element was not present in the map)
func (ConcurrentMap) Set ¶ added in v2.2.0
func (m ConcurrentMap) Set(key string, value interface{})
Sets the given value under the specified key.
func (ConcurrentMap) SetIfAbsent ¶ added in v2.2.0
func (m ConcurrentMap) SetIfAbsent(key string, value interface{}) bool
Sets the given value under the specified key if no value was associated with it.
func (ConcurrentMap) Upsert ¶ added in v2.2.0
func (m ConcurrentMap) Upsert(key string, value interface{}, cb UpsertCb) (res interface{})
Insert or Update - updates existing element or inserts a new one using UpsertCb
type ConcurrentMapShared ¶ added in v2.2.0
type ConcurrentMapShared struct { // contains filtered or unexported fields }
A "thread" safe string to anything map.
type ConnectionPoolDBHandle ¶ added in v2.2.0
type ConnectionPoolDBHandle struct {
// contains filtered or unexported fields
}
func NewConnectionPoolDBHandle ¶ added in v2.2.0
func NewConnectionPoolDBHandle(size int, log protocol.Logger) *ConnectionPoolDBHandle
func (*ConnectionPoolDBHandle) Clear ¶ added in v2.2.0
func (c *ConnectionPoolDBHandle) Clear()
func (*ConnectionPoolDBHandle) GetDBHandle ¶ added in v2.2.0
func (c *ConnectionPoolDBHandle) GetDBHandle(contractName string) (protocol.SqlDBHandle, bool)
func (*ConnectionPoolDBHandle) SetDBHandle ¶ added in v2.2.0
func (c *ConnectionPoolDBHandle) SetDBHandle(contractName string, handle protocol.SqlDBHandle)
type EngineType ¶
type EngineType int32
EngineType database type
const ( UnknownDb EngineType = 0 LevelDb EngineType = 1 TikvDb EngineType = 2 MySQL EngineType = 3 Sqlite EngineType = 4 BadgerDb EngineType = 5 )
nolint
func (EngineType) LowerString ¶
func (t EngineType) LowerString() string
func (EngineType) String ¶
func (t EngineType) String() string
type HistoryIteratorImpl ¶
type HistoryIteratorImpl struct {
// contains filtered or unexported fields
}
func NewHistoryIterator ¶
func NewHistoryIterator(contractName string, key []byte, dbItr historydb.HistoryIterator, resultStore resultdb.ResultDB, blockStore BlockGetter) *HistoryIteratorImpl
func (*HistoryIteratorImpl) Next ¶
func (hs *HistoryIteratorImpl) Next() bool
func (*HistoryIteratorImpl) Release ¶
func (hs *HistoryIteratorImpl) Release()
func (*HistoryIteratorImpl) Value ¶
func (hs *HistoryIteratorImpl) Value() (*storePb.KeyModification, error)
type IterCb ¶ added in v2.2.0
type IterCb func(key string, v interface{})
Iterator callback,called for every key,value found in maps. RLock is held for all calls for a given shard therefore callback sess consistent view of a shard, but not across the shards
type RemoveCb ¶ added in v2.2.0
RemoveCb is a callback executed in a map.RemoveCb() call, while Lock is held If returns true, the element will be removed from the map
type SavePoint ¶
type SavePoint struct {
BlockHeight uint64 `gorm:"primarykey"`
}
func (*SavePoint) GetInsertSql ¶
type SqlVerifyPass ¶
type SqlVerifyPass struct { }
SqlVerifyPass 用于测试场景,不对SQL语句进行检查,任意SQL检查都通过
func (*SqlVerifyPass) VerifyDDLSql ¶
func (s *SqlVerifyPass) VerifyDDLSql(sql string) error
func (*SqlVerifyPass) VerifyDMLSql ¶
func (s *SqlVerifyPass) VerifyDMLSql(sql string) error
func (*SqlVerifyPass) VerifyDQLSql ¶
func (s *SqlVerifyPass) VerifyDQLSql(sql string) error
type StandardSqlVerify ¶
type StandardSqlVerify struct { }
StandardSqlVerify 如果状态数据库是标准SQL语句,对标准SQL的SQL语句进行语法检查,不关心具体的SQL DB类型的语法差异
func (*StandardSqlVerify) VerifyDDLSql ¶
func (s *StandardSqlVerify) VerifyDDLSql(sql string) error
func (*StandardSqlVerify) VerifyDMLSql ¶
func (s *StandardSqlVerify) VerifyDMLSql(sql string) error
func (*StandardSqlVerify) VerifyDQLSql ¶
func (s *StandardSqlVerify) VerifyDQLSql(sql string) error
type Tuple ¶ added in v2.2.0
type Tuple struct { Key string Val interface{} }
Used by the Iter & IterBuffered functions to wrap two variables together over a channel,
type TxHistoryIteratorImpl ¶
type TxHistoryIteratorImpl struct {
// contains filtered or unexported fields
}
func NewTxHistoryIterator ¶
func NewTxHistoryIterator(dbItr historydb.HistoryIterator, blockStore BlockGetter) *TxHistoryIteratorImpl
func (*TxHistoryIteratorImpl) Next ¶
func (hs *TxHistoryIteratorImpl) Next() bool
func (*TxHistoryIteratorImpl) Release ¶
func (hs *TxHistoryIteratorImpl) Release()
func (*TxHistoryIteratorImpl) Value ¶
func (hs *TxHistoryIteratorImpl) Value() (*storePb.TxHistory, error)
type UpdateBatch ¶
type UpdateBatch struct {
// contains filtered or unexported fields
}
UpdateBatch encloses the details of multiple `updates`
func (*UpdateBatch) Delete ¶
func (batch *UpdateBatch) Delete(key []byte)
Delete deletes a Key and associated value
func (*UpdateBatch) Get ¶ added in v2.1.1
func (batch *UpdateBatch) Get(key []byte) ([]byte, error)
func (*UpdateBatch) Has ¶ added in v2.1.1
func (batch *UpdateBatch) Has(key []byte) bool
func (*UpdateBatch) KVs ¶
func (batch *UpdateBatch) KVs() map[string][]byte
KVs return map, only read
func (*UpdateBatch) Keys ¶ added in v2.2.0
func (batch *UpdateBatch) Keys() []string
return keys in map
func (*UpdateBatch) Len ¶
func (batch *UpdateBatch) Len() int
Len returns the number of entries in the batch
func (*UpdateBatch) Merge ¶
func (batch *UpdateBatch) Merge(u protocol.StoreBatcher)
Merge merges other kvs to this updateBatch
func (*UpdateBatch) ReSet ¶ added in v2.2.0
func (batch *UpdateBatch) ReSet()
KVs return map, only read
func (*UpdateBatch) SplitBatch ¶
func (batch *UpdateBatch) SplitBatch(batchCnt uint64) []protocol.StoreBatcher
SplitBatch split other kvs to more updateBatchs division by batchCnt batchCnt: 拆分后,每个子batch,最多包含多少个k/v
type UpsertCb ¶ added in v2.2.0
type UpsertCb func(exist bool, valueInMap interface{}, newValue interface{}) interface{}
Callback to return new element to be inserted into the map It is called while lock is held, therefore it MUST NOT try to access other keys in same map, as it can lead to deadlock since Go sync.RWLock is not reentrant