blockchain

package
v0.0.0-...-75b6e65 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBlock

func HashBlock(previousBlockHash string, currentBlockData BlockData, nonce int) string

HashBlock - sha256 hash of block Ref: https://github.com/openblockchains/awesome-sha256/blob/master/hash.go

func ProofOfWork

func ProofOfWork(previousBlockHash string, currentBlockData BlockData) int

ProofOfWork Algorithm

Types

type Block

type Block struct {
	Hash              string
	Index             int
	Nonce             int
	PreviousBlockHash string
	Timestamp         int64
	Transactions      []Transaction
}

Block structure

type BlockData

type BlockData struct {
	Index        int
	Transactions []Transaction
}

BlockData structure

type Blockchain

type Blockchain struct {
	Chain               []Block
	PendingTransactions []Transaction
}

Blockchain structure

var B Blockchain

B - The Blockchain

func CreateNewBlockchain

func CreateNewBlockchain() Blockchain

CreateNewBlockchain - Function to create new chain

func (*Blockchain) AddMinedBlockToChain

func (b *Blockchain) AddMinedBlockToChain(newBlock Block)

AddMinedBlockToChain add block

func (*Blockchain) AddTransactionToPendingTransactions

func (b *Blockchain) AddTransactionToPendingTransactions(transaction Transaction) int

AddTransactionToPendingTransactions to add transaction to chain

func (*Blockchain) GetLastBlock

func (b *Blockchain) GetLastBlock() Block

GetLastBlock of blockchain

func (*Blockchain) MineBlock

func (b *Blockchain) MineBlock() Block

MineBlock of blockchain

func (*Blockchain) NewBlock

func (b *Blockchain) NewBlock(nonce int, previousBlockHash string, hash string) Block

NewBlock - To create new block

func (*Blockchain) PublishChain

func (b *Blockchain) PublishChain(replyQueue string)

PublishChain for peer nodes to sync

func (*Blockchain) RequestChain

func (b *Blockchain) RequestChain()

RequestChain Method

func (*Blockchain) SynchroniseChain

func (b *Blockchain) SynchroniseChain(chain Blockchain)

SynchroniseChain Method

type ChainRequest

type ChainRequest struct {
	ReplyQueue string
}

ChainRequest Structure

type Transaction

type Transaction struct {
	Checksum      string
	Data          string
	DataCategory  string
	Recipient     string
	Sender        string
	TransactionID string
}

Transaction structure

func NewTransaction

func NewTransaction(data string, dataCategory string, sender string, recipient string) Transaction

NewTransaction to create new transaction

Jump to

Keyboard shortcuts

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