storage

package
v0.0.0-...-5e63da4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR_MSG = "Initiate storage aborted: "
)

Variables

View Source
var (
	State    = make(map[[32]byte]*protocol.Account)
	RootKeys = make(map[[32]byte]*protocol.Account)

	DifferentSenders         = make(map[[32]byte]uint32)
	DifferentReceivers       = make(map[[32]byte]uint32)
	FundsTxBeforeAggregation = make([]*protocol.FundsTx, 0)

	AllClosedBlocksAsc []*protocol.Block
	Bootstrap_Server   string
)

Functions

func BlockReadyToAggregate

func BlockReadyToAggregate(block *protocol.Block) bool

func DeleteAll

func DeleteAll()

func DeleteAllFundsTxBeforeAggregation

func DeleteAllFundsTxBeforeAggregation()

func DeleteAllLastClosedBlock

func DeleteAllLastClosedBlock()

func DeleteBootstrapReceivedMempool

func DeleteBootstrapReceivedMempool()

func DeleteClosedBlock

func DeleteClosedBlock(hash [32]byte)

func DeleteClosedTx

func DeleteClosedTx(transaction protocol.Transaction)

func DeleteFundsTxBeforeAggregation

func DeleteFundsTxBeforeAggregation(hash [32]byte) bool

func DeleteINVALIDOpenTx

func DeleteINVALIDOpenTx(transaction protocol.Transaction)

func DeleteLastClosedBlock

func DeleteLastClosedBlock(hash [32]byte)

func DeleteOpenBlock

func DeleteOpenBlock(hash [32]byte)

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

func DeleteOpenTx

func DeleteOpenTx(transaction protocol.Transaction)

func DeleteOpenTxWithHash

func DeleteOpenTxWithHash(transactionHash [32]byte)

func GetAccTxPubKeys

func GetAccTxPubKeys(accTxData [][32]byte) (accTxPubKeys [][32]byte)

Get all pubKey involved in AccTx

func GetAccount

func GetAccount(hash [32]byte) (acc *protocol.Account, err error)

Needed by miner and p2p package

func GetFundsTxPubKeys

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

Get all pubKey involved in FundsTx

func GetRootAccount

func GetRootAccount(hash [32]byte) (acc *protocol.Account, err error)

func GetTxPubKeys

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

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

func Init

func Init(dbname string, bootstrapIpport string)

Entry function for the storage package

func InitLogger

func InitLogger() *log.Logger

func IsRootKey

func IsRootKey(hash [32]byte) bool

func ReadAllBootstrapReceivedTransactions

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

func ReadAllClosedBlocks

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

This method does read all blocks in closedBlocks & closedblockswithouttx.

func ReadAllOpenTxs

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

Needed for the miner to prepare a new block

func ReadBootstrapReceivedTransactions

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

func ReadClosedBlock

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

func ReadClosedBlockWithoutTx

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

This function does read all blocks without transactions inside.

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 ReadFundsTxBeforeAggregation

func ReadFundsTxBeforeAggregation() []*protocol.FundsTx

func ReadINVALIDOpenTx

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

func ReadLastClosedBlock

func ReadLastClosedBlock() (block *protocol.Block)

func ReadMempool

func ReadMempool()

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 ReadOpenTx

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

func ReadReceivedBlockStash

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

func TearDown

func TearDown()

func UpdateBlocksToBlocksWithoutTx

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

func WriteAccount

func WriteAccount(account *protocol.Account)

func WriteBootstrapTxReceived

func WriteBootstrapTxReceived(transaction protocol.Transaction)

func WriteClosedBlock

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

func WriteClosedBlockWithoutTx

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

func WriteClosedTx

func WriteClosedTx(transaction protocol.Transaction) (err error)

func WriteFundsTxBeforeAggregation

func WriteFundsTxBeforeAggregation(transaction *protocol.FundsTx)

func WriteINVALIDOpenTx

func WriteINVALIDOpenTx(transaction protocol.Transaction)

func WriteLastClosedBlock

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

func WriteOpenBlock

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

func WriteOpenTx

func WriteOpenTx(transaction protocol.Transaction)

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

func WriteToReceivedStash

func WriteToReceivedStash(block *protocol.Block)

Types

type ByHeight

type ByHeight []*protocol.Block

The three functions and the type below are used to order the gathered closed blocks from below according to their block height.

func (ByHeight) Len

func (a ByHeight) Len() int

func (ByHeight) Less

func (a ByHeight) Less(i, j int) bool

func (ByHeight) Swap

func (a ByHeight) Swap(i, j int)

Jump to

Keyboard shortcuts

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