database

package
v3.8.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 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"
)
View Source
const (
	IntPrefix      = "i"
	StringPrefix   = "s"
	NilPrefix      = "n"
	BoolPrefix     = "b"
	JSONPrefix     = "j"
	FixPointPrefix = "f"
)

const prefixs

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 MapKeysSeparator = "@"

MapKeysSeparator separator of value

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 RAMOwnerSeparator = "@"

These two values are same... a historical mistake

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.NewDecimalFromIntWithScale(100000, 2)

GasImmediateReward immediate reward per IOST

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

GasIncreaseRate gas increase per IOST per second

View Source
var GasLimit = common.NewDecimalFromIntWithScale(300000, 2)

GasLimit gas limit per IOST

View Source
var GasMinPledgeOfUser = common.NewDecimalFromIntWithScale(10, 8)

GasMinPledgeOfUser Each user must pledge a minimum amount of IOST

View Source
var GasMinPledgePerAction = common.NewDecimalFromIntWithScale(1, 8)

GasMinPledgePerAction One must (un)pledge more than 1 IOST

Functions

func EmptyGas

func EmptyGas() *common.Decimal

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 any, extras ...string) (string, error)

Marshal marshal go types to value string

func MustMarshal

func MustMarshal(in any, extra ...string) string

MustMarshal marshal go types to value string, panic on error

func MustUnmarshal

func MustUnmarshal(o string) any

MustUnmarshal unmarshal value string to go types, panic on error

func MustUnmarshalWithExtra

func MustUnmarshalWithExtra(o string) (any, string)

MustUnmarshalWithExtra unmarshal value string to go types, panic on error

func Unmarshal

func Unmarshal(o string) any

Unmarshal unmarshal value string to go types

func UnmarshalWithExtra

func UnmarshalWithExtra(o string) (any, string)

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

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

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

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

type FreezeItem struct {
	Amount int64
	Ftime  int64
}

FreezeItem represents freezed balance, will unfreeze after Ftime

type FreezeItemFixed

type FreezeItemFixed struct {
	Amount common.Decimal
	Ftime  int64
}

FreezeItemFixed ...

type GasHandler

type GasHandler struct {
	BasicHandler
	MapHandler
}

GasHandler easy to get balance of token.iost

func (*GasHandler) GasLimit

func (g *GasHandler) GasLimit(name string) *common.Decimal

GasLimit ...

func (*GasHandler) GasPledge

func (g *GasHandler) GasPledge(name string, pledger string) *common.Decimal

GasPledge ...

func (*GasHandler) GasPledgeTotal

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

GasPledgeTotal ...

func (*GasHandler) GasStock

func (g *GasHandler) GasStock(name string) *common.Decimal

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.Decimal)

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.Decimal)

TotalGasAtTime return total gas at given time..

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

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

type Mode int

Mode of this record

const (
	Default Mode = iota
	Delete
)

const enum of Mode

type PledgerInfo

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

PledgerInfo ...

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

func (*RAMHandler) BuyPrice

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

func (r *RAMHandler) LeftRAM() int64

LeftRAM ...

func (*RAMHandler) SellPrice

func (r *RAMHandler) SellPrice() float64

SellPrice ...

func (*RAMHandler) TotalRAM

func (r *RAMHandler) TotalRAM() int64

TotalRAM ...

func (*RAMHandler) UsedRAM

func (r *RAMHandler) UsedRAM() int64

UsedRAM ...

type Record

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

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

TokenHandler easy to get balance of token.iost

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

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

TokenBalanceFixed get token balance of acc

type Visitor

Visitor combine of every handler, to be api of database

func NewBatchVisitor

func NewBatchVisitor(lruDB *LRU) *Visitor

NewBatchVisitor get visitor with mapper

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.Decimal, error)

GetProducerVotes ...

type WriteCache

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

WriteCache ...

func NewWriteCache

func NewWriteCache(db database) *WriteCache

NewWriteCache ...

func (*WriteCache) Del

func (w *WriteCache) Del(key string)

Del ...

func (*WriteCache) Drop

func (w *WriteCache) Drop()

Drop ...

func (*WriteCache) Flush

func (w *WriteCache) Flush()

Flush ...

func (*WriteCache) Get

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

Get ...

func (*WriteCache) Has

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

Has ...

func (*WriteCache) Put

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