blockchain

package
v0.0.0-...-921adc7 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotFound = errors.New("block not found")
View Source
var ErrorUnknown = errors.New("unknown")

Functions

This section is empty.

Types

type Block

type Block interface {
	// CalculateHash calculates hash using sha256.
	// CalculateHash()
	// Mine mines the hash.
	Mine()
	// GetData gets data of the block.
	GetData() string
	// GetPrevHash gets hash data of the previous block.
	GetPrevHash() string
}

type Blockchain

type Blockchain interface {
	// AddBlock adds data to blockchain.
	AddBlock(data string) error
	// AllBlocks gets all the blocks of this blockchain.
	AllBlocks() ([]Block, error)
	// PrintBlock just prints all the blocks.
	PrintBlock()
	// GetBlock gets block at the height of this blockchain.
	GetBlock(hash string) (Block, error)
	// GetNewestHash gets newest hash of this blockchain.
	GetNewestHash() string
	// GetHeight gets height of this blockchain.
	GetHeight() int
	// Close closes blockchain.
	Close() error
}

Jump to

Keyboard shortcuts

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