block

package
v3.11.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const MaxTransactionCount = uint64(math.MaxUint64) / types.HashSize

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)

GetBlockReward Taken from https://github.com/monero-project/monero/blob/b0bf49a65a38ceb1acfbc8e17f40e63383ac140d/src/cryptonote_basic/cryptonote_basic_impl.cpp#L83

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, compact, pruned, containsAuxiliaryTemplateId 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, canBePruned bool, f PrunedFlagsFunc) (err error)

func (*Block) FromReader

func (b *Block) FromReader(reader utils.ReaderAndByteReader, canBePruned bool, f PrunedFlagsFunc) (err error)

func (*Block) FromReaderFlags

func (b *Block) FromReaderFlags(reader utils.ReaderAndByteReader, compact, canBePruned bool, f PrunedFlagsFunc) (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(compact, pruned, containsAuxiliaryTemplateId 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, canBePruned bool, f PrunedFlagsFunc) 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"`
}

type PrunedFlagsFunc added in v3.4.0

type PrunedFlagsFunc func() (containsAuxiliaryTemplateId bool)

Jump to

Keyboard shortcuts

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