database

package
v3.3.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2019 License: LGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package database is a generated GoMock package.

Index

Constants

View Source
const (
	// GasPledgeTotalKey : how many IOST is pledged
	GasPledgeTotalKey = "gt"
	// 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 = "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"
)
View Source
const (
	IntPrefix       = "i"
	StringPrefix    = "s"
	NilPrefix       = "n"
	BoolPrefix      = "b"
	JSONPrefix      = "j"
	MapHolderPrefix = "@"
	FixPointPrefix  = "f"
)

const prefixs

View Source
const ApplicationSeparator = "@"

ApplicationSeparator separator of value

View Source
const BasicPrefix = "b-"

BasicPrefix prefix of basic types

View Source
const ContractPrefix = "c-"

ContractPrefix ...

View Source
const GasContractName = "gas.iost"

GasContractName name of basic token contract

View Source
const (
	GasDecimal = 2
)

decimals of gas

View Source
const GasFulfillSeconds int64 = 2 * 24 * 3600

GasFulfillSeconds it takes 2 days to fulfill the gas buffer.

View Source
const IOSTRatio int64 = 100000000

IOSTRatio ...

View Source
const MapPrefix = "m-"

MapPrefix prefix of map key

View Source
const RAMContractName = "ram.iost"

RAMContractName name of basic token contract

View Source
const Separator = "-"

Separator separator of map key

View Source
const (
	// StateTable name
	StateTable = "state"
)
View Source
const Token721ContractName = "token721.iost"

Token721ContractName name of basic token contract

View Source
const TokenContractName = "token.iost"

TokenContractName name of basic token contract

View Source
const VoteContractName = "vote.iost"

VoteContractName name of common vote contract

View Source
const VoteProducerContractName = "vote_producer.iost"

VoteProducerContractName name of vote producer contract

Variables

View Source
var GasImmediateReward = &common.Fixed{Value: 100000 * 100, Decimal: 2}

GasImmediateReward immediate reward per IOST

View Source
var GasIncreaseRate = GasLimit.Sub(GasImmediateReward).Div(GasFulfillSeconds)

GasIncreaseRate gas increase per IOST per second

View Source
var GasLimit = &common.Fixed{Value: 300000 * 100, Decimal: 2}

GasLimit gas limit per IOST

View Source
var GasMinPledgeOfUser = &common.Fixed{Value: 10 * IOSTRatio, Decimal: 8}

GasMinPledgeOfUser Each user must pledge a minimum amount of IOST

View Source
var GasMinPledgePerAction = &common.Fixed{Value: 1 * IOSTRatio, Decimal: 8}

GasMinPledgePerAction One must (un)pledge more than 1 IOST

Functions

func EmptyGas added in v1.1.0

func EmptyGas() *common.Fixed

EmptyGas ...

func LoadBlockhead

func LoadBlockhead(path string) (*block.BlockHead, error)

LoadBlockhead load block info as block.BlockHead from json file

func LoadTxInfo

func LoadTxInfo(path string) (*tx.Tx, error)

LoadTxInfo load tx info as tx.Tx from json file

func Marshal

func Marshal(in interface{}, extras ...string) (string, error)

Marshal marshal go types to value string

func MustMarshal

func MustMarshal(in interface{}, extra ...string) 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

func MustUnmarshalWithExtra added in v1.1.0

func MustUnmarshalWithExtra(o string) (interface{}, string)

MustUnmarshalWithExtra unmarshal value string to go types, panic on error

func NewBatchVisitor added in v1.1.0

func NewBatchVisitor(lruDB *LRU) (*Visitor, Mapper)

NewBatchVisitor get visitor with mapper

func Unmarshal

func Unmarshal(o string) interface{}

Unmarshal unmarshal value string to go types

func UnmarshalWithExtra added in v1.1.0

func UnmarshalWithExtra(o string) (interface{}, string)

UnmarshalWithExtra unmarshal value string to go types

Types

type Access added in v1.1.0

type Access int

Access enum of type of access

const (
	Read Access = iota
	Write
)

const .

type AccountRAMInfo

type AccountRAMInfo struct {
	// Used ...
	Used int64
	// Available ...
	Available int64
	// Total ...
	Total int64
}

AccountRAMInfo ...

type AccountVoteInfo

type AccountVoteInfo struct {
	Option       string
	Votes        *common.Fixed
	ClearedVotes *common.Fixed
}

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

func (*BasicHandler) Get

func (m *BasicHandler) Get(key string) (value string)

Get get v from k

func (*BasicHandler) Has

func (m *BasicHandler) Has(key string) bool

Has determine if k exist

func (*BasicHandler) Put

func (m *BasicHandler) Put(key, value string)

Put put to k-v

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) GetDelaytx

func (m *DelaytxHandler) GetDelaytx(txHash string) (string, string)

GetDelaytx gets the delay tx's publisher and deferTxHash.

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, publisher, deferTxHash string)

StoreDelaytx stores delaytx hash.

type FreezeItem added in v1.1.0

type FreezeItem struct {
	Amount int64
	Ftime  int64
}

FreezeItem represents freezed balance, will unfreeze after Ftime

type FreezeItemFixed added in v1.1.0

type FreezeItemFixed struct {
	Amount common.Fixed
	Ftime  int64
}

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) GasPledgeTotal

func (g *GasHandler) GasPledgeTotal(name string) *common.Fixed

GasPledgeTotal ...

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 I pledged how much coins for others

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)
}

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, rules *version.Rules) *LRU

NewBatchVisitorRoot get LRU to next step

func NewLRU

func NewLRU(length int, db database) *LRU

NewLRU make a new lru

func (*LRU) Del

func (m *LRU) Del(key string)

Del delete key from cache

func (*LRU) Get

func (m *LRU) Get(key string) (value string)

Get get from cache

func (*LRU) Has

func (m *LRU) Has(key string) bool

Has if key exist

func (*LRU) Purge

func (m *LRU) Purge()

Purge delete all keys

func (*LRU) Put

func (m *LRU) Put(key, value string)

Put put kv to cache

func (*LRU) Rules

func (m *LRU) Rules() *version.Rules

Rules get rules of db

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 Mapper added in v1.1.0

type Mapper interface {
	Map() map[string]Access
}

Mapper generator of conflict map

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) Commit

func (m *MockIMultiValue) Commit()

Commit mocks base method

func (*MockIMultiValue) Del

func (m *MockIMultiValue) Del(arg0, arg1 string) error

Del mocks base method

func (*MockIMultiValue) EXPECT

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

func (*MockIMultiValue) Rollback

func (m *MockIMultiValue) Rollback()

Rollback 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 Mode added in v1.1.0

type Mode int

Mode of this record

const (
	Default Mode = iota
	Delete
)

const enum of Mode

type PledgerInfo added in v1.1.0

type PledgerInfo struct {
	Pledger string
	Amount  *common.Fixed
}

PledgerInfo ...

type ProducerVoteInfo

type ProducerVoteInfo struct {
	Pubkey     string
	Loc        string
	URL        string
	NetID      string
	IsProducer bool
	Status     string
	Online     bool
}

ProducerVoteInfo ...

type RAMHandler added in v1.1.0

type RAMHandler struct {
	BasicHandler
}

RAMHandler easy to get balance of token.iost

func (*RAMHandler) BuyPrice added in v1.1.0

func (r *RAMHandler) BuyPrice() float64

BuyPrice ...

func (*RAMHandler) ChangeUsedRAMInfo

func (r *RAMHandler) ChangeUsedRAMInfo(acc string, delta int64)

ChangeUsedRAMInfo ...

func (*RAMHandler) GetAccountRAMInfo

func (r *RAMHandler) GetAccountRAMInfo(acc string) *AccountRAMInfo

GetAccountRAMInfo ...

func (*RAMHandler) LeftRAM added in v1.1.0

func (r *RAMHandler) LeftRAM() int64

LeftRAM ...

func (*RAMHandler) SellPrice added in v1.1.0

func (r *RAMHandler) SellPrice() float64

SellPrice ...

func (*RAMHandler) TotalRAM added in v1.1.0

func (r *RAMHandler) TotalRAM() int64

TotalRAM ...

func (*RAMHandler) UsedRAM added in v1.1.0

func (r *RAMHandler) UsedRAM() int64

UsedRAM ...

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) Commit

func (m *RollbackHandler) Commit()

Commit commit a MVCC version

func (*RollbackHandler) Rollback

func (m *RollbackHandler) Rollback()

Rollback rollback to newest MVCC version

type SerializedJSON

type SerializedJSON []byte

SerializedJSON type of Serialized json

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

func NewDatabaseFromPath(path string) *SimpleDB

NewDatabaseFromPath returns a SimpleDB with data loaded from json file

func (*SimpleDB) AddSystem

func (d *SimpleDB) AddSystem(path string)

AddSystem load system contract and data from json file

func (*SimpleDB) Commit

func (d *SimpleDB) Commit()

Commit do nothing

func (*SimpleDB) Del

func (d *SimpleDB) Del(table string, key string) error

Del delete key from db

func (*SimpleDB) Get

func (d *SimpleDB) Get(table string, key string) (string, error)

Get key-value from db with marshal

func (*SimpleDB) Has

func (d *SimpleDB) Has(table string, key string) (bool, error)

Has return if key exists in db

func (*SimpleDB) Keys

func (d *SimpleDB) Keys(table string, prefix string) ([]string, error)

Keys do nothing

func (*SimpleDB) Load

func (d *SimpleDB) Load(path string) error

Load load db data from json file

func (*SimpleDB) Put

func (d *SimpleDB) Put(table string, key string, value string) error

Put key-value into db with unmarshal

func (*SimpleDB) Rollback

func (d *SimpleDB) Rollback()

Rollback do nothing

func (*SimpleDB) Save

func (d *SimpleDB) Save(path string) error

Save save db data to json file

type Token721Handler

type Token721Handler struct {
	// contains filtered or unexported fields
}

Token721Handler easy to get balance of token.iost

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 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

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.iost and vote_producer.iost

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 added in v1.1.0

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher of db access

func NewWatcher added in v1.1.0

func NewWatcher(db database) *Watcher

NewWatcher ...

func (*Watcher) Del added in v1.1.0

func (r *Watcher) Del(key string)

Del ...

func (*Watcher) Get added in v1.1.0

func (r *Watcher) Get(key string) (value string)

Get record and get

func (*Watcher) Has added in v1.1.0

func (r *Watcher) Has(key string) bool

Has ...

func (*Watcher) Map added in v1.1.0

func (r *Watcher) Map() map[string]Access

Map map the access of this watcher

func (*Watcher) Put added in v1.1.0

func (r *Watcher) Put(key, value string)

Put ...

type WriteCache added in v1.1.0

type WriteCache struct {
	// contains filtered or unexported fields
}

WriteCache ...

func NewWriteCache added in v1.1.0

func NewWriteCache(db database) *WriteCache

NewWriteCache ...

func (*WriteCache) Del added in v1.1.0

func (w *WriteCache) Del(key string)

Del ...

func (*WriteCache) Drop added in v1.1.0

func (w *WriteCache) Drop()

Drop ...

func (*WriteCache) Flush added in v1.1.0

func (w *WriteCache) Flush()

Flush ...

func (*WriteCache) Get added in v1.1.0

func (w *WriteCache) Get(key string) (value string)

Get ...

func (*WriteCache) Has added in v1.1.0

func (w *WriteCache) Has(key string) bool

Has ...

func (*WriteCache) Put added in v1.1.0

func (w *WriteCache) Put(key, value string)

Put ...

func (*WriteCache) Rules

func (w *WriteCache) Rules() *version.Rules

Rules ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL