CMACPoW

package
v0.0.0-...-3c37bd4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntToHex

func IntToHex(num int64) []byte

IntToHex converts an int64 to a byte array

func ReverseBytes

func ReverseBytes(data []byte)

ReverseBytes reverses a byte array

func Serialize

func Serialize(obj any) []byte

Types

type Block

type Block struct {
	Timestamp int64
	PrevHash  []byte
	Hash      []byte
	Data      []byte
	Height    int64
	DiffNum   uint
	Nonce     int64
	CMAC      []byte
}

func DeserializeBlock

func DeserializeBlock(d []byte) *Block

func NewBlock

func NewBlock(data string, prevHash []byte, height int64) *Block

func NewGenesisBlock

func NewGenesisBlock() *Block

func (*Block) SetHash

func (b *Block) SetHash()

type Blockchain

type Blockchain struct {
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(dbFile string) *Blockchain

func (*Blockchain) AddBlock

func (bc *Blockchain) AddBlock(data string)

func (*Blockchain) BlockChainIteration

func (bc *Blockchain) BlockChainIteration()

func (*Blockchain) NewIterator

func (bc *Blockchain) NewIterator() *BlockchainIterator

type BlockchainIterator

type BlockchainIterator struct {
	// contains filtered or unexported fields
}

func (*BlockchainIterator) Next

func (i *BlockchainIterator) Next() *Block

type ProofOfWork

type ProofOfWork struct {
	// contains filtered or unexported fields
}

func NewProofOfWork

func NewProofOfWork(b *Block) *ProofOfWork

func (*ProofOfWork) Mine

func (pow *ProofOfWork) Mine() (int64, []byte, []byte)

func (*ProofOfWork) PrepareData

func (pow *ProofOfWork) PrepareData(nonce int64) []byte

func (*ProofOfWork) Validate

func (pow *ProofOfWork) Validate() bool

Jump to

Keyboard shortcuts

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