Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeHash ¶
calculateHash calculates the hash of a block
func IsGenesisBlock ¶
IsGenesisBlock checks if the block is the genesis block
func VerifyBlock ¶
VerifyBlock checks if the block signature is valid
Types ¶
type Block ¶
type Block struct { Header Transactions []transaction.Transaction `json:"transactions"` }
func DeserializeBlock ¶
DeserializeBlock converts a byte slice back into a Block
func NewBlock ¶
func NewBlock(transactions []transaction.Transaction, prevBlockHash []byte, height uint32, minerAddr ecdsa.KeyPair) *Block
NewBlock creates a new block using the provided transactions and the previous block hash
func (*Block) ComputeMerkleRoot ¶
calculateMerkleRoot computes the Merkle root of the transactions in the block
func (*Block) GetTransactionIDsMap ¶
func (b *Block) GetTransactionIDsMap() map[string]transaction.Transaction
type Header ¶
type Header struct { Version uint32 `json:"version"` // Blockchain version PrevBlock []byte `json:"prev_block"` // 256-bit hash of the previous block header MerkleRoot []byte `json:"merkle_root"` // 256-bit hash based on all of the transactions in the block TargetBits uint32 `json:"target_bits"` // Target bits is a way to set the mining difficulty Timestamp int64 `json:"timestamp"` // Current timestamp as seconds since 1970-01-01T00:00 UTC Height uint32 `json:"height"` // Block height Nonce uint32 `json:"nonce"` // 32-bit number (starts at 0) used to generate the required hash MinerAddr []byte `json:"miner_addr"` // ECDSA public key of the miner Signature []byte `json:"signature"` // ECDSA signature of the block header }
Click to show internal directories.
Click to hide internal directories.