storage

package
v0.0.0-...-c6cf726 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 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)
	ReceivedBlockStash       = make([]*protocol.Block, 0)
	TxcntToTxMap             = make(map[uint32][][32]byte)
	AllClosedBlocksAsc       []*protocol.Block
	Bootstrap_Server         string

	ReceivedBlockStashMutex = &sync.Mutex{}
)

Functions

func BlockAlreadyInStash

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

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 DeleteClosedBlockWithoutTx

func DeleteClosedBlockWithoutTx(hash [32]byte)

func DeleteClosedTx

func DeleteClosedTx(transaction protocol.Transaction)

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

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

func ReadAllClosedFundsAndAggTransactions

func ReadAllClosedFundsAndAggTransactions() (allClosedTransactions []protocol.Transaction)

func ReadAllINVALIDOpenTx

func ReadAllINVALIDOpenTx() (allOpenInvalidTxs []protocol.Transaction)

func ReadAllOpenTxs

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

Needed for the miner to prepare a new block

func ReadBlockByTxHash

func ReadBlockByTxHash(txHash [32]byte) (block *protocol.Block)

Returns the block which contains the given tx hash.

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

func ReadTxcntToTx(txCnt uint32) (transactions [][32]byte)

func TearDown

func TearDown()

func UpdateBlocksToBlocksWithoutTx

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

func WriteBlockHashByTxHash

func WriteBlockHashByTxHash(txHash [32]byte, bHash [32]byte) (err error)

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)

func WriteTxcntToTx

func WriteTxcntToTx(transaction *protocol.FundsTx)

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