templates

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: Unlicense Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var F, E, W, I, D, T log.LevelPrinter = log.GetLogPrinterSet(subsystem)

Functions

This section is empty.

Types

type Diffs

type Diffs map[int32]uint32

Diffs is a bundle of difficulty bits

type Merkles

type Merkles map[int32]chainhash.Hash

Merkles is a bundle of merkle roots

type Message

type Message struct {
	Nonce     uint64
	UUID      uint64
	Height    int32
	PrevBlock chainhash.Hash
	Bits      Diffs
	Merkles   Merkles

	Timestamp time.Time
	// contains filtered or unexported fields
}

Message describes a message that a mining worker can use to construct a block to mine on, as well the extra data required to reconstruct any version block mined by the miner

func DeserializeMsgBlockTemplate

func DeserializeMsgBlockTemplate(b []byte) (m *Message)

DeserializeMsgBlockTemplate takes a message expected to be a Message and reconstitutes it

func (*Message) GenBlockHeader

func (m *Message) GenBlockHeader(vers int32) *wire.BlockHeader

GenBlockHeader generate a block given a version number to use for mining The nonce is empty, date can be updated, version changes merkle and target bits. All the data required for this is in the exported fields that are serialized for over the wire

func (*Message) GetTxs

func (m *Message) GetTxs() (txs map[int32][]*wire.MsgTx)

GetTxs returns the transactions

func (*Message) Reconstruct

func (m *Message) Reconstruct(hdr *wire.BlockHeader) (mb *wire.Block, e error)

Reconstruct takes a received block from the wire and reattaches the transactions

func (*Message) Serialize

func (m *Message) Serialize() []byte

Serialize the Message for the wire

func (*Message) SetTxs

func (m *Message) SetTxs(ver int32, txs []*wire.MsgTx)

SetTxs writes to the private, non-serialized transactions field

type RecentMessages

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

RecentMessages keeps a buffer of four previously created messages so that solutions found after a new template is created can be submitted

func NewRecentMessages

func NewRecentMessages() *RecentMessages

func (*RecentMessages) Add

func (rm *RecentMessages) Add(msg *Message)

Add a message to the RecentMessages, we just write to the current cursor position, and then advance it, back to zero if it exceeds the buffer length, overwriting the first, and so on

func (*RecentMessages) Find

func (rm *RecentMessages) Find(nonce uint64) *Message

Find checks whether the given nonce matches any of the cached Message's and remove it from the list

func (*RecentMessages) Len

func (rm *RecentMessages) Len() (o int)

Len returns the number of elements in the buffer

type Txs

type Txs map[int32][]*wire.MsgTx

Txs is a set of transactions

Jump to

Keyboard shortcuts

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