blockchain

package
v0.0.0-...-dfd7d4b Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

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

Block struct represents a chain's block

func (*Block) ComputeBlockHash

func (block *Block) ComputeBlockHash() string

ComputeBlockHash calculates the base-64 encoding of the SHA-256 block checksum

func (*Block) ComputeDigitalSignature

func (block *Block) ComputeDigitalSignature(ks keyStore.KeyStore) (*DigitalSignature, error)

ComputeDigitalSignature computes the digital signature of a block, given a KeyStore

func (*Block) LinkToPreviousBlock

func (block *Block) LinkToPreviousBlock()

LinkToPreviousBlock takes the block's predecessor, and links it to the current block

func (*Block) SetBlockHash

func (block *Block) SetBlockHash(blockHash string)

SetBlockHash is a simple setter

func (*Block) Sign

func (block *Block) Sign(ks keyStore.KeyStore)

Sign computes the digital signature of a block, given a KeyStore, and signs it

type BlockChain

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

BlockChain struct represent a basic BlockChain model

func (*BlockChain) CreateGenesisBlock

func (blockChain *BlockChain) CreateGenesisBlock(data string) Block

CreateGenesisBlock starts the chain by creating its header block

func (*BlockChain) IsValid

func (blockChain *BlockChain) IsValid(block *Block) bool

IsValid checks, given a block in the chain, its expected hash against its current hash then carries on the check for its successors to assert the chain's integrity

func (*BlockChain) SaveBlock

func (blockChain *BlockChain) SaveBlock(block *Block)

SaveBlock calculates a block hash given its previous block, creates the link between the two and inserts it in the chain

type DigitalSignature

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

type IBlock

type IBlock interface {
	ComputeBlockHash() string
	SetBlockHash(blockHash string)
	LinkToPreviousBlock()
	ComputeDigitalSignature()
	Sign()
}

IBlock is the generic interface implemented by the blocks

type IBlockChain

type IBlockChain interface {
	SaveBlock(bock Block)
}

IBlockChain is the generic interface implemented by our BlockChain model

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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