util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 7 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	// header of this block.
	Header

	// Transactions of this block.
	Transactions []Transaction
}

Block represent a block that stored in the blockchain database.

type BlockHeader

type BlockHeader interface {
	Previous() common.Uint256
	Bits() uint32
	MerkleRoot() common.Uint256
	Hash() common.Uint256
	PowHash() common.Uint256
	Serialize(w io.Writer) error
	Deserialize(r io.Reader) error
}

type Filter

type Filter interface {
	Add(data []byte)
	Matches(data []byte) bool
}
type Header struct {
	// The origin header of the block
	BlockHeader

	Height uint32

	// MerkleProof for transactions packed in this block
	NumTxs uint32
	Hashes []*common.Uint256
	Flags  []byte

	// The total work from the genesis block to this
	// current block
	TotalWork *big.Int
}

Header is a data structure stored in database.

func (*Header) Deserialize

func (h *Header) Deserialize(b []byte) error

func (*Header) Serialize

func (h *Header) Serialize() ([]byte, error)

type OutPoint

type OutPoint struct {
	TxID  common.Uint256
	Index uint16
}

func NewOutPoint

func NewOutPoint(txId common.Uint256, index uint16) *OutPoint

func OutPointFromBytes

func OutPointFromBytes(value []byte) (*OutPoint, error)

func (*OutPoint) Bytes

func (op *OutPoint) Bytes() []byte

func (*OutPoint) Deserialize

func (op *OutPoint) Deserialize(r io.Reader) error

func (*OutPoint) IsEqual

func (op *OutPoint) IsEqual(o OutPoint) bool

func (*OutPoint) Serialize

func (op *OutPoint) Serialize(w io.Writer) error

type Transaction

type Transaction interface {
	Hash() common.Uint256
	Serialize(w io.Writer) error
	Deserialize(r io.Reader) error
	MatchFilter(filter Filter) bool
}

type Tx

type Tx struct {
	// The transaction hash.
	Hash common.Uint256

	// The block height that this transaction
	// belongs to.
	Height uint32

	// The time the transaction was first seen
	Timestamp time.Time

	// Transaction
	RawData []byte
}

Tx is a data structure used in database.

func NewTx

func NewTx(tx Transaction, height uint32) *Tx

func (*Tx) Deserialize

func (t *Tx) Deserialize(r io.Reader) error

func (*Tx) Serialize

func (t *Tx) Serialize(w io.Writer) error

Jump to

Keyboard shortcuts

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