blockchain

package
v0.0.0-...-942cd0b Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MainGenesisBlockBytes, _ = hex.DecodeString("0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c")
	TestGenesisBlockBytes, _ = hex.DecodeString("0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff001d1aa4ae18")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	Version    uint32   // Block version, based on the software version creating this block.
	PrevBlock  [32]byte // The hash value of the previous block this particular block references.
	MerkleRoot [32]byte // Merkle tree hash of all transactions related to this block.
	Timestamp  uint32   // A timestamp recording when this block was created (limited to 2106).
	Bits       [4]byte  // The calculated difficulty target being used for this block.
	Nonce      [4]byte  // The nonce used to generate this block.
}

Block represents a Bitcoin block header, the metadata of a block.

func (*Block) Difficulty

func (b *Block) Difficulty() *big.Int

Difficulty returns the block (current mining) difficulty based on the bits. Difficulty is simply a human interpretable form of the target. The difficulty of the genesis block is 1. The formula is as follows:

difficulty = (target of lowest difficulty) / (current target)

func (*Block) Id

func (b *Block) Id() string

func (*Block) Marshal

func (b *Block) Marshal() [80]byte

func (*Block) Target

func (b *Block) Target() *big.Int

Target returns the PoW target based on the bits.

func (*Block) Unmarshal

func (b *Block) Unmarshal(r io.Reader) *Block

func (*Block) VerifyPoW

func (b *Block) VerifyPoW() bool

VerifyPoW returns whether this block satisfies the PoW.

Jump to

Keyboard shortcuts

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