storage

package
v0.0.0-...-c7fdbca Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR_MSG                   = "Storage initialization aborted. Reason: "
	OPENBLOCKS_BUCKET           = "openblocks"
	CLOSEDBLOCKS_BUCKET         = "closedblocks"
	CLOSEDFUNDS_BUCKET          = "closedfunds"
	CLOSEDACCS_BUCKET           = "closedaccs"
	CLOSEDSTAKES_BUCKET         = "closedstakes"
	CLOSEDCONFIGS_BUCKET        = "closedconfigs"
	LASTCLOSEDBLOCK_BUCKET      = "lastclosedblock"
	GENESIS_BUCKET              = "genesis"
	CLOSEDEPOCHBLOCK_BUCKET     = "closedepochblocks"
	LASTCLOSEDEPOCHBLOCK_BUCKET = "lastclosedepochblocks"
	OPENEPOCHBLOCK_BUCKET       = "openepochblock"
)

Variables

View Source
var (
	State = make(map[[64]byte]*protocol.Account)
	//This map keeps track of the relative account adjustments within a shard, such as balance, txcount and stakingheight
	RelativeState = make(map[[64]byte]*protocol.RelativeAccount)
	RootKeys      = make(map[[64]byte]*protocol.Account)

	ReceivedStateStash      = protocol.NewStateStash()
	OwnBlockStash           []*protocol.Block
	OwnStateTransitionStash []*protocol.StateTransition
	AllClosedBlocksAsc      []*protocol.Block
	BootstrapServer         string
	Buckets                 []string

	ThisShardID int // ID of the shard this validator is assigned to

	ReceivedBlockStash = make([]*protocol.Block, 0)
)

Functions

func ApplyRelativeState

func ApplyRelativeState(statePrev map[[64]byte]*protocol.Account, stateRel map[[64]byte]*protocol.RelativeAccount) (stateUpdated map[[64]byte]*protocol.Account)

func BlockAlreadyInStash

func BlockAlreadyInStash(slice []*protocol.Block, newBlockHash [32]byte) bool

func CreateBucket

func CreateBucket(bucketName string, db *bolt.DB) (err error)

func DeleteAccount

func DeleteAccount(address [64]byte)

func DeleteAll

func DeleteAll() (err error)

func DeleteAllLastClosedBlock

func DeleteAllLastClosedBlock() error

func DeleteAllLastClosedEpochBlock

func DeleteAllLastClosedEpochBlock() error

func DeleteBucket

func DeleteBucket(bucketName string, db *bolt.DB) (err error)

func DeleteClosedBlock

func DeleteClosedBlock(hash [32]byte) error

func DeleteClosedEpochBlock

func DeleteClosedEpochBlock(hash [32]byte) error

func DeleteClosedTx

func DeleteClosedTx(transaction protocol.Transaction) error

func DeleteINVALIDOpenTx

func DeleteINVALIDOpenTx(transaction protocol.Transaction)

func DeleteLastClosedBlock

func DeleteLastClosedBlock(hash [32]byte) error

func DeleteOpenBlock

func DeleteOpenBlock(hash [32]byte) error

There exist open/closed buckets and closed tx buckets for all types (open txs are in volatile storage)

func DeleteOpenEpochBlock

func DeleteOpenEpochBlock(hash [32]byte) error

func DeleteOpenTx

func DeleteOpenTx(transaction protocol.Transaction)

func GetContractTxPubKeys

func GetContractTxPubKeys(contractTxData [][32]byte) (contractTxPubKeys [][64]byte)

Get all pubKey involved in ContractTx

func GetFundsTxPubKeys

func GetFundsTxPubKeys(fundsTxData [][32]byte) (fundsTxPubKeys [][64]byte)

Get all pubKey involved in FundsTx

func GetMemPoolSize

func GetMemPoolSize() int

func GetRelativeState

func GetRelativeState(statePrev map[[64]byte]protocol.Account, stateNow map[[64]byte]*protocol.Account) (stateRel map[[64]byte]*protocol.RelativeAccount)

func GetTxPubKeys

func GetTxPubKeys(block *protocol.Block) (txPubKeys [][64]byte)

Get all pubKeys involved in ContractTx, FundsTx of a given block

func Init

func Init(dbname string, bootstrapIpport string) error

Entry function for the storage package

func InitFileLogger

func InitFileLogger() *log.Logger

func InitLogger

func InitLogger() *log.Logger

func IsRootKey

func IsRootKey(pubKey [64]byte) bool

func ReadAccount

func ReadAccount(pubKey [64]byte) (acc *protocol.Account, err error)

func ReadAllClosedBlocks

func ReadAllClosedBlocks() (allClosedBlocks []*protocol.Block)

func ReadAllOpenTxs

func ReadAllOpenTxs() (allOpenTxs []protocol.Transaction)

Needed for the miner to prepare a new block

func ReadBlockFromOwnStash

func ReadBlockFromOwnStash(height int) *protocol.Block

func ReadClosedBlock

func ReadClosedBlock(hash [32]byte) (block *protocol.Block)

func ReadClosedEpochBlock

func ReadClosedEpochBlock(hash [32]byte) (epochBlock *protocol.EpochBlock)

func ReadClosedTx

func ReadClosedTx(hash [32]byte) (transaction protocol.Transaction)

Personally I like it better to test (which tx type it is) here, and get returned the interface. Simplifies the code

func ReadFirstEpochBlock

func ReadFirstEpochBlock() (firstEpochBlock *protocol.EpochBlock, err error)

func ReadGenesis

func ReadGenesis() (genesis *protocol.Genesis, err error)

func ReadINVALIDOpenTx

func ReadINVALIDOpenTx(hash [32]byte) (transaction protocol.Transaction)

func ReadLastClosedBlock

func ReadLastClosedBlock() (block *protocol.Block)

func ReadLastClosedEpochBlock

func ReadLastClosedEpochBlock() (epochBlock *protocol.EpochBlock)

func ReadOpenBlock

func ReadOpenBlock(hash [32]byte) (block *protocol.Block)

Always return nil if requested hash is not in the storage. This return value is then checked against by the caller

func ReadOpenEpochBlock

func ReadOpenEpochBlock(hash [32]byte) (epochBlock *protocol.EpochBlock)

func ReadOpenTx

func ReadOpenTx(hash [32]byte) (transaction protocol.Transaction)

func ReadReceivedBlockStash

func ReadReceivedBlockStash() (receivedBlocks []*protocol.Block)

func ReadRootAccount

func ReadRootAccount(pubKey [64]byte) (acc *protocol.Account, err error)

func ReadStateTransitionFromOwnStash

func ReadStateTransitionFromOwnStash(height int) *protocol.StateTransition

func TearDown

func TearDown()

func WriteAccount

func WriteAccount(account *protocol.Account)

func WriteClosedBlock

func WriteClosedBlock(block *protocol.Block) error

func WriteClosedEpochBlock

func WriteClosedEpochBlock(epochBlock *protocol.EpochBlock) error

func WriteClosedTx

func WriteClosedTx(transaction protocol.Transaction) error

func WriteFirstEpochBlock

func WriteFirstEpochBlock(epochBlock *protocol.EpochBlock) error

func WriteGenesis

func WriteGenesis(genesis *protocol.Genesis) error

func WriteINVALIDOpenTx

func WriteINVALIDOpenTx(transaction protocol.Transaction)

func WriteLastClosedBlock

func WriteLastClosedBlock(block *protocol.Block) (err error)

func WriteLastClosedEpochBlock

func WriteLastClosedEpochBlock(epochBlock *protocol.EpochBlock) (err error)

func WriteOpenBlock

func WriteOpenBlock(block *protocol.Block) error

func WriteOpenEpochBlock

func WriteOpenEpochBlock(epochBlock *protocol.EpochBlock) error

func WriteOpenTx

func WriteOpenTx(transaction protocol.Transaction)

Changing the "tx" shortcut here and using "transaction" to distinguish between bolt's transactions

func WriteToOwnBlockStash

func WriteToOwnBlockStash(block *protocol.Block)

func WriteToOwnStateTransitionkStash

func WriteToOwnStateTransitionkStash(st *protocol.StateTransition)

func WriteToReceivedStash

func WriteToReceivedStash(block *protocol.Block)

Types

This section is empty.

Jump to

Keyboard shortcuts

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