miner

package
v0.18.3-beta Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HarnessNetParams = &chaincfg.RegressionNetParams

	// temp is used to signal we want to establish a temporary connection
	// using the btcd Node API.
	//
	// NOTE: Cannot be const, since the node API expects a reference.
	Temp = "temp"
)

Functions

This section is empty.

Types

type HarnessMiner

type HarnessMiner struct {
	*testing.T
	*rpctest.Harness
	// contains filtered or unexported fields
}

func NewMiner

func NewMiner(ctxt context.Context, t *testing.T) *HarnessMiner

NewMiner creates a new miner using btcd backend with the default log file dir and name.

func NewTempMiner

func NewTempMiner(ctxt context.Context, t *testing.T,
	tempDir, tempLogFilename string) *HarnessMiner

NewTempMiner creates a new miner using btcd backend with the specified log file dir and name.

func (*HarnessMiner) AssertMinerBlockHeightDelta

func (h *HarnessMiner) AssertMinerBlockHeightDelta(tempMiner *HarnessMiner,
	delta int32)

AssertMinerBlockHeightDelta ensures that tempMiner is 'delta' blocks ahead of miner.

func (*HarnessMiner) AssertNumTxsInMempool

func (h *HarnessMiner) AssertNumTxsInMempool(n int) []*chainhash.Hash

AssertNumTxsInMempool polls until finding the desired number of transactions in the provided miner's mempool. It will asserrt if this number is not met after the given timeout.

func (*HarnessMiner) AssertOutpointInMempool

func (h *HarnessMiner) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx

AssertOutpointInMempool asserts a given outpoint can be found in the mempool.

func (*HarnessMiner) AssertTxInBlock

func (h *HarnessMiner) AssertTxInBlock(block *wire.MsgBlock,
	txid *chainhash.Hash)

AssertTxInBlock asserts that a given txid can be found in the passed block.

func (*HarnessMiner) AssertTxInMempool

func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx

AssertTxInMempool asserts a given transaction can be found in the mempool.

func (*HarnessMiner) AssertTxNotInMempool

func (h *HarnessMiner) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx

AssertTxNotInMempool asserts a given transaction cannot be found in the mempool. It assumes the mempool is not empty.

NOTE: this should be used after `AssertTxInMempool` to ensure the tx has entered the mempool before. Otherwise it might give false positive and the tx may enter the mempool after the check.

func (*HarnessMiner) ConnectMiner

func (h *HarnessMiner) ConnectMiner(tempMiner *HarnessMiner)

ConnectMiner connects the miner to a temp miner.

func (*HarnessMiner) CreateTransaction

func (h *HarnessMiner) CreateTransaction(outputs []*wire.TxOut,
	feeRate btcutil.Amount) *wire.MsgTx

CreateTransaction uses the miner to create a transaction using the given outputs using the specified fee rate and returns the transaction.

func (*HarnessMiner) DisconnectMiner

func (h *HarnessMiner) DisconnectMiner(tempMiner *HarnessMiner)

DisconnectMiner disconnects the miner from the temp miner.

func (*HarnessMiner) GenerateBlocks

func (h *HarnessMiner) GenerateBlocks(num uint32) []*chainhash.Hash

GenerateBlocks mine 'num' of blocks and returns them.

func (*HarnessMiner) GetBestBlock

func (h *HarnessMiner) GetBestBlock() (*chainhash.Hash, int32)

GetBestBlock makes a RPC request to miner and asserts.

func (*HarnessMiner) GetBlock

func (h *HarnessMiner) GetBlock(blockHash *chainhash.Hash) *wire.MsgBlock

GetBlock gets a block using its block hash.

func (*HarnessMiner) GetNumTxsFromMempool

func (h *HarnessMiner) GetNumTxsFromMempool(n int) []*wire.MsgTx

GetNumTxsFromMempool polls until finding the desired number of transactions in the miner's mempool and returns the full transactions to the caller.

func (*HarnessMiner) GetRawMempool

func (h *HarnessMiner) GetRawMempool() []*chainhash.Hash

GetRawMempool makes a RPC call to the miner's GetRawMempool and asserts.

func (*HarnessMiner) GetRawTransaction

func (h *HarnessMiner) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx

GetRawTransaction makes a RPC call to the miner's GetRawTransaction and asserts.

func (*HarnessMiner) GetRawTransactionVerbose

func (h *HarnessMiner) GetRawTransactionVerbose(
	txid *chainhash.Hash) *btcjson.TxRawResult

GetRawTransactionVerbose makes a RPC call to the miner's GetRawTransactionVerbose and asserts.

func (*HarnessMiner) MineBlockWithTx

func (h *HarnessMiner) MineBlockWithTx(tx *wire.MsgTx) *wire.MsgBlock

MineBlocksWithTx mines a single block to include the specifies tx only.

func (*HarnessMiner) MineBlockWithTxes

func (h *HarnessMiner) MineBlockWithTxes(txes []*btcutil.Tx) *wire.MsgBlock

MineBlocksWithTxes mines a single block to include the specifies transactions only.

func (*HarnessMiner) MineBlocks

func (h *HarnessMiner) MineBlocks(num uint32) []*wire.MsgBlock

MineBlocks mine 'num' of blocks and check that blocks are present in node blockchain.

func (*HarnessMiner) MineBlocksAndAssertNumTxes

func (h *HarnessMiner) MineBlocksAndAssertNumTxes(num uint32,
	numTxs int) []*wire.MsgBlock

MineBlocksAndAssertNumTxes mine 'num' of blocks and check that blocks are present in node blockchain. numTxs should be set to the number of transactions (excluding the coinbase) we expect to be included in the first mined block.

func (*HarnessMiner) MineBlocksSlow

func (h *HarnessMiner) MineBlocksSlow(num uint32) []*wire.MsgBlock

MineBlocksSlow mines 'num' of blocks. Between each mined block an artificial delay is introduced to give all network participants time to catch up.

func (*HarnessMiner) MineEmptyBlocks

func (h *HarnessMiner) MineEmptyBlocks(num int) []*wire.MsgBlock

MineEmptyBlocks mines a given number of empty blocks.

func (*HarnessMiner) NewMinerAddress

func (h *HarnessMiner) NewMinerAddress() btcutil.Address

NewMinerAddress creates a new address for the miner and asserts.

func (*HarnessMiner) SendOutput

func (h *HarnessMiner) SendOutput(newOutput *wire.TxOut,
	feeRate btcutil.Amount) *chainhash.Hash

SendOutput creates, signs, and finally broadcasts a transaction spending the harness' available mature coinbase outputs to create the new output.

func (*HarnessMiner) SendOutputsWithoutChange

func (h *HarnessMiner) SendOutputsWithoutChange(outputs []*wire.TxOut,
	feeRate btcutil.Amount) *chainhash.Hash

SendOutputsWithoutChange uses the miner to send the given outputs using the specified fee rate and returns the txid.

func (*HarnessMiner) SpawnTempMiner

func (h *HarnessMiner) SpawnTempMiner() *HarnessMiner

SpawnTempMiner creates a temp miner and syncs it with the current miner. Once miners are synced, the temp miner is disconnected from the original miner and returned.

func (*HarnessMiner) Stop

func (h *HarnessMiner) Stop()

Stop shuts down the miner and saves its logs.

Jump to

Keyboard shortcuts

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