mockblock

package
v0.0.0-...-3b62c27 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChainDebugger

func NewChainDebugger(w io.Writer, users []key.Sender) *chaindebugger

Types

type Chain

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

Chain is an in memory blockchain used for testing

func NewChain

func NewChain(user key.Receiver) *Chain

NewChain returns a new block from the data and previous hash.

func (*Chain) Append

func (c *Chain) Append(blk *block.Block)

Append will append a block to the end of the chain

func (*Chain) Base

func (c *Chain) Base() (*block.Block, error)

Base returns the base of the chain

func (*Chain) BlockByIndex

func (c *Chain) BlockByIndex(i int) *block.Block

BlockByIndex indexes the underlying array of blocks

func (*Chain) Get

func (c *Chain) Get(h []byte) (*block.Block, error)

Get will get a block given it's hash

func (*Chain) Head

func (c *Chain) Head() (*block.Block, error)

Head gets the head block

func (*Chain) HeadHash

func (c *Chain) HeadHash() []byte

HeadHash returns the has of the head block

func (*Chain) Iter

func (c *Chain) Iter() block.Iterator

Iter returns a block iterator

func (*Chain) Len

func (c *Chain) Len() int

Len returns the number of blocks

func (*Chain) Push

func (c *Chain) Push(blk *block.Block) error

Push will push a new block onto the chain

func (*Chain) Transaction

func (c *Chain) Transaction(id []byte) *block.Transaction

Transaction will get a transaction

type Engine

type Engine struct {
	Chain block.Chain
	UTXO  block.UTXOSet
	// contains filtered or unexported fields
}

Engine is a type that is meant to facilitate randomized transactions for the purpose of testing

func NewEngine

func NewEngine(t *testing.T, chain block.Chain, users []key.Sender) *Engine

func (*Engine) SetSeed

func (e *Engine) SetSeed(seed int64)

func (*Engine) Step

func (e *Engine) Step(n int) error

Step will run through n steps of the transaction generation engine.

type TransactionBuilder

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

func (*TransactionBuilder) Append

func (txb *TransactionBuilder) Append(d block.TxDesc) error

func (*TransactionBuilder) BuildTransactions

func (txb *TransactionBuilder) BuildTransactions(f block.TxFinder) ([]*block.Transaction, error)

func (*TransactionBuilder) Reset

func (txb *TransactionBuilder) Reset()

Jump to

Keyboard shortcuts

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