blockchain

package
v0.0.0-...-0ad7415 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntToByte

func IntToByte(o int64) []byte

Types

type Block

type Block struct {
	Timestamp    int64
	Data         []byte
	PreBlockHash []byte
	Hash         []byte
	Nonce        int
}

func Deserialize

func Deserialize(blockBytes []byte) *Block

func NewBlock

func NewBlock(data string, preBlockHash []byte) *Block

func NewGenesisBlock

func NewGenesisBlock() *Block

func (*Block) Serialize

func (r *Block) Serialize() []byte

type BlockChain

type BlockChain struct {
	DB *bolt.DB
	// contains filtered or unexported fields
}

func NewBlockChain

func NewBlockChain() *BlockChain

func (*BlockChain) AddBlock

func (r *BlockChain) AddBlock(data string)

func (*BlockChain) ForEach

func (r *BlockChain) ForEach(fn func(k []byte, v []byte) error) error

func (*BlockChain) GetBlock

func (r *BlockChain) GetBlock(hash []byte) *Block

type ChainIterator

type ChainIterator struct {
	DB *bolt.DB
	// contains filtered or unexported fields
}

type ProofOfWork

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

ProofOfWork POW

func NewProofOfWork

func NewProofOfWork(b *Block) *ProofOfWork

NewProofOfWork say something

func (*ProofOfWork) Run

func (r *ProofOfWork) Run() (int, []byte)

Run calc POW

func (*ProofOfWork) Valid

func (r *ProofOfWork) Valid() bool

Valid check POW

Jump to

Keyboard shortcuts

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