services

package
v0.0.0-...-e95280a Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	Block() Block
	MinedBlock() MinedBlock
	Link() Link
	MinedLink() MinedLink
	Chain() Chain
}

Application represents the blockchain application

func NewApplication

func NewApplication(
	block Block,
	minedBlock MinedBlock,
	link Link,
	minedLink MinedLink,
	chain Chain,
) Application

NewApplication creates a new application instance

type Block

type Block interface {
	Create(hashes []hash.Hash) (blocks.Block, error)
	Delete(hash hash.Hash) error
}

Block represents a block application

func NewBlock

func NewBlock(
	blockRepository blocks.Repository,
	blockService blocks.Service,
) Block

NewBlock creates a new block application instance

type Chain

type Chain interface {
	Update(id *uuid.UUID) error
	Delete(id *uuid.UUID) error
	Sync(waitPeriod time.Duration)
	Create(
		id *uuid.UUID,
		miningValue uint8,
		blockBaseDifficulty uint,
		blockIncreaseDiffPerHash float64,
		linkDifficulty uint,
		initialHashes []hash.Hash,
	) (chains.Chain, error)
}

Chain represents a chain application

func NewChain

func NewChain(
	peerSyncInterval time.Duration,
	remoteAppBuilder repositories.RemoteBuilder,
	chainService chains.Service,
	blockApp Block,
	minedBlockApp MinedBlock,
	minedLinkApp MinedLink,
	minedLinkRepository repositories.MinedLink,
	chainRepositoryApp repositories.Chain,
) Chain

NewChain creates a new chain application instance

type Link interface {
	Create(prevMinedLinkHash hash.Hash, nextBlockHash hash.Hash) (links.Link, error)
	Delete(hash hash.Hash) error
}

Link represents the link application

func NewLink(
	linkService links.Service,
	blockRepository repositories.Block,
	linkRepository repositories.Link,
	minedLinkRepository repositories.MinedLink,
) Link

NewLink creates a new link application instance

type MinedBlock

type MinedBlock interface {
	Mine(miningValue uint8, baseDifficulty uint, incrPerHash float64, blockHash hash.Hash) (mined_block.Block, error)
	MineList(miningValue uint8, baseDifficulty uint, incrPerHash float64) ([]mined_block.Block, error)
	Delete(hash hash.Hash) error
}

MinedBlock represents the mined block application

func NewMinedBlock

func NewMinedBlock(
	mineBlockService mined_block.Service,
	mineBlockRepositoryApp repositories.MinedBlock,
	blockRepositoryApp repositories.Block,
	minerApp Miner,
) MinedBlock

NewMinedBlock creates a new mined block application instance

type MinedLink interface {
	Mine(miningValue uint8, difficulty uint, linkHash hash.Hash) (mined_link.Link, error)
	MineList(miningValue uint8, difficulty uint) ([]mined_link.Link, error)
	Delete(hash hash.Hash) error
}

MinedLink represents the mined link application

func NewMinedLink(
	minedLinkService mined_link.Service,
	linkRepositoryApp repositories.Link,
	minedLinkRepositoryApp repositories.MinedLink,
	minerApp Miner,
) MinedLink

NewMinedLink creates a new mined link application instance

type Miner

type Miner interface {
	Test(difficulty uint) (string, *time.Duration, error)
	Mine(miningValue uint8, difficulty uint, hash hash.Hash) (string, *time.Duration, error)
}

Miner represents a miner application

func NewMiner

func NewMiner() Miner

NewMiner creates a new miner application instance

Jump to

Keyboard shortcuts

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