block

package
v0.0.0-...-d7dfbf7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBaseReward

func GetBaseReward(alreadyGeneratedCounts uint64) uint64

func GetBlockReward

func GetBlockReward(medianWeight, currentBlockWeight, alreadyGeneratedCoins uint64, version uint8) (reward uint64)

Types

type Block

type Block struct {
	MajorVersion uint8 `json:"major_version"`
	MinorVersion uint8 `json:"minor_version"`
	// Nonce re-arranged here to improve memory layout space
	Nonce uint32 `json:"nonce"`

	Timestamp  uint64     `json:"timestamp"`
	PreviousId types.Hash `json:"previous_id"`

	Coinbase transaction.CoinbaseTransaction `json:"coinbase"`

	Transactions []types.Hash `json:"transactions,omitempty"`
	// TransactionParentIndices amount of reward existing Outputs. Used by p2pool serialized compact broadcasted blocks in protocol >= 1.1, filled only in compact blocks or by pre-processing.
	TransactionParentIndices []uint64 `json:"transaction_parent_indices,omitempty"`
}

func (*Block) AppendBinaryFlags

func (b *Block) AppendBinaryFlags(preAllocatedBuf []byte, pruned, compact bool) (buf []byte, err error)

func (*Block) BufferLength

func (b *Block) BufferLength() int

func (*Block) Difficulty

func (*Block) FromCompactReader

func (b *Block) FromCompactReader(reader utils.ReaderAndByteReader) (err error)

func (*Block) FromReader

func (b *Block) FromReader(reader utils.ReaderAndByteReader) (err error)

func (*Block) FromReaderFlags

func (b *Block) FromReaderFlags(reader utils.ReaderAndByteReader, compact bool) (err error)

func (*Block) HashingBlob

func (b *Block) HashingBlob(preAllocatedBuf []byte) []byte

func (*Block) HashingBlobBufferLength

func (b *Block) HashingBlobBufferLength() int

func (*Block) Header

func (b *Block) Header() *Header

func (*Block) HeaderBlob

func (b *Block) HeaderBlob(preAllocatedBuf []byte) []byte

func (*Block) HeaderBlobBufferLength

func (b *Block) HeaderBlobBufferLength() int

func (*Block) Id

func (b *Block) Id() types.Hash

func (*Block) MarshalBinary

func (b *Block) MarshalBinary() (buf []byte, err error)

func (*Block) MarshalBinaryFlags

func (b *Block) MarshalBinaryFlags(pruned, compact bool) (buf []byte, err error)

func (*Block) PowHashWithError

func (b *Block) PowHashWithError(hasher randomx.Hasher, f GetSeedByHeightFunc) (types.Hash, error)

func (*Block) SideChainHashingBlob

func (b *Block) SideChainHashingBlob(preAllocatedBuf []byte, zeroTemplateId bool) (buf []byte, err error)

SideChainHashingBlob Same as MarshalBinary but with nonce or template id set to 0

func (*Block) UnmarshalBinary

func (b *Block) UnmarshalBinary(data []byte) error

type GetBlockHeaderByHashFunc

type GetBlockHeaderByHashFunc func(hash types.Hash) *Header

type GetBlockHeaderByHeightFunc

type GetBlockHeaderByHeightFunc func(height uint64) *Header

type GetDifficultyByHeightFunc

type GetDifficultyByHeightFunc func(height uint64) types.Difficulty

type GetSeedByHeightFunc

type GetSeedByHeightFunc func(height uint64) (hash types.Hash)
type Header struct {
	MajorVersion uint8 `json:"major_version"`
	MinorVersion uint8 `json:"minor_version"`
	// Nonce re-arranged here to improve memory layout space
	Nonce uint32 `json:"nonce"`

	Timestamp  uint64     `json:"timestamp"`
	PreviousId types.Hash `json:"previous_id"`
	Height     uint64     `json:"height"`
	//Nonce would be here
	Reward     uint64           `json:"reward"`
	Difficulty types.Difficulty `json:"difficulty"`
	Id         types.Hash       `json:"id"`
}

Jump to

Keyboard shortcuts

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