blockchain

package
v0.0.0-...-47da8ba Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const Difficulty = 12

Variables

This section is empty.

Functions

func ToHex

func ToHex(num int64) []byte

Types

type Block

type Block struct {
	gorm.Model
	Hash     []byte
	BottleId []byte
	OwnerId  []byte
	PrevHash []byte
	Nonce    int
}

func CreateBlock

func CreateBlock(bottleId string, ownerID string, prevHash []byte) *Block

func Genesis

func Genesis() *Block

type BlockChain

type BlockChain struct {
	Blocks []*Block
}

func InitBlockChain

func InitBlockChain() *BlockChain

func (*BlockChain) AddBlock

func (chain *BlockChain) AddBlock(data *Data) *Block

type Data

type Data struct {
	BottleId string
	OwnerId  string
}

type ProofOfWork

type ProofOfWork struct {
	Block  *Block
	Target *big.Int
}

func NewProofOfWork

func NewProofOfWork(b *Block) *ProofOfWork

func (*ProofOfWork) InitNonce

func (pow *ProofOfWork) InitNonce(nonce int) []byte

func (*ProofOfWork) Run

func (pow *ProofOfWork) Run() (int, []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