books

package
v0.0.0-...-d1fccd7 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2019 License: GPL-3.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomTransactions

func RandomTransactions(bm *Accounts, numTransactions int, keyPairs []block.KeyPair, vdfValue []byte) (*block.Transactions, uint64)

RandomTransactions returns random transactions and number of transactions that will be processed successfully. Only for testing!

func RandomTransactionsBlocks

func RandomTransactionsBlocks(bm *Accounts, numTransactionsPerBlock int, numBlocks int, keyPairs []block.KeyPair) []block.Block

RandomTransactionsBlocks generates blocks with random transactions between real accounts, for testing

func SignatureVerification

func SignatureVerification(packetReceiver <-chan *network.Packets) <-chan *network.Packets

SignatureVerification accepts Packets verifies them and sends verified only Packets to the output channel

func TransactionGenerator

func TransactionGenerator(bm *Accounts, packetReceiver <-chan *network.Packets) <-chan *block.Transactions

TransactionGenerator is responsible for creating Transactions. It should receive raw data through transactionReceiver channel and deserialize it(implement deserialization later) For now TransactionGenerator receives Transactions.

Types

type Accounts

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

Accounts stores account balances and ledger info.

func NewBookManager

func NewBookManager() *Accounts

NewBookManager creates new Accounts object

func RandomAccounts

func RandomAccounts(numAccounts int) (*Accounts, []block.KeyPair)

RandomAccounts creates bank with random accounts, for testing

func (*Accounts) AddValidVDFValue

func (bm *Accounts) AddValidVDFValue(val block.VDFValue)

AddValidVDFValue adds last seen vdf value to the ledger

func (*Accounts) Balance

func (bm *Accounts) Balance(publicKey ed25519.PublicKey) int64

Balance method returns balance of account with public key equals publicKey. NOTE: Only for testing.

func (*Accounts) BlocksTotal

func (bm *Accounts) BlocksTotal() uint64

BlocksTotal returns count of processed blocks

func (*Accounts) Clone

func (bm *Accounts) Clone() *Accounts

Clone method returns clone of Accounts struct

func (*Accounts) CreateAccount

func (bm *Accounts) CreateAccount(publicKey ed25519.PublicKey, amount int64)

CreateAccount creates new account with initial balance. NOTE: Only for testing.

func (*Accounts) Equals

func (bm *Accounts) Equals(bm2 *Accounts) bool

Equals compares two Accounts and returns true if they have same accounts with same balances

func (*Accounts) IncreaseBlocksTotal

func (bm *Accounts) IncreaseBlocksTotal()

IncreaseBlocksTotal increases Block Count

func (*Accounts) LastBlock

func (bm *Accounts) LastBlock() *block.Block

LastBlock returns last block registered in legder

func (*Accounts) ProcessBlocks

func (bm *Accounts) ProcessBlocks(blocks []block.Block) (err error)

ProcessBlocks process a list of blocks. TODO: change copying transactions

func (*Accounts) ProcessTransactions

func (bm *Accounts) ProcessTransactions(trans block.Transactions) block.Transactions

ProcessTransactions process a batch of transactions.

func (*Accounts) RandomKeys

func (bm *Accounts) RandomKeys(num uint64) []ed25519.PublicKey

RandomKeys returns account keys, which are used as default account list on web monitoring tool

func (*Accounts) String

func (bm *Accounts) String() string

String method prints accounts balances. NOTE: Only for testing.

func (*Accounts) TransactionsTotal

func (bm *Accounts) TransactionsTotal() uint64

TransactionsTotal returns count of transactions

func (*Accounts) UpdateLastBlock

func (bm *Accounts) UpdateLastBlock(bl *block.Block)

UpdateLastBlock updates last block in ledger and counts number of blocks

func (*Accounts) ValidVDFValue

func (bm *Accounts) ValidVDFValue() []byte

ValidVDFValue returns the valid vdf value registered.

type Ledger

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

Ledger struct is responsible to save last vdf values For each VDFValue we store a set of Signatures. This way we can determine which signature came with which VDFValue

func (*Ledger) AddValidVDFValue

func (l *Ledger) AddValidVDFValue(vdfVal block.VDFValue)

AddValidVDFValue registers new vdf value. typically used when producer is sending blocks to the network.

func (*Ledger) Clone

func (l *Ledger) Clone() *Ledger

Clone returns clone of Ledger object

func (*Ledger) Equals

func (l *Ledger) Equals(l2 *Ledger) bool

Equals compares two Ledger objects, for testing

func (*Ledger) LastBlock

func (l *Ledger) LastBlock() *block.Block

LastBlock returns last block registered in the ledger

func (*Ledger) UpdateLastBlock

func (l *Ledger) UpdateLastBlock(bl *block.Block)

UpdateLastBlock updates last block in ledger. last block means a block with the highest number(height).

Jump to

Keyboard shortcuts

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