blockchain

package
v0.0.0-...-bc7c564 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOrder    = errors.New("Unexpected block index")
	ErrFutureTimestamp = errors.New("Block time is too far in the future")
	ErrParentNotFound  = errors.New("Parent block not found")
)

Functions

This section is empty.

Types

type Blockchain

type Blockchain struct {
	BlocksUpdates chan safebox.SerializedBlock
	TxPoolUpdates chan tx.CommonOperation
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(fn NewSafeboxCallback, s storage.Storage, height *uint32) (*Blockchain, error)

func (*Blockchain) AccountOperationsForEach

func (b *Blockchain) AccountOperationsForEach(number uint32, offset uint32, limit uint32, fn func(operationId uint32, meta *tx.TxMetadata, tx tx.CommonOperation) bool) error

func (*Blockchain) AddAlternateChain

func (this *Blockchain) AddAlternateChain(blocks []safebox.SerializedBlock) error

func (*Blockchain) BlockOperationsForEach

func (this *Blockchain) BlockOperationsForEach(index uint32, fn func(meta *tx.TxMetadata, tx tx.CommonOperation) bool) error

func (*Blockchain) ExportSafebox

func (this *Blockchain) ExportSafebox() []byte

func (*Blockchain) GetAccount

func (this *Blockchain) GetAccount(number uint32) *accounter.Account

func (*Blockchain) GetAccountsByPublicKey

func (b *Blockchain) GetAccountsByPublicKey(public *crypto.Public) []uint32

func (*Blockchain) GetBlock

func (this *Blockchain) GetBlock(index uint32) (safebox.BlockBase, error)

func (*Blockchain) GetBlockPow

func (this *Blockchain) GetBlockPow(block safebox.BlockBase) []byte

func (*Blockchain) GetBlockTemplate

func (b *Blockchain) GetBlockTemplate(miner *crypto.Public, payload []byte, time *uint32, nonce uint32) (block safebox.BlockBase, template []byte, reservedOffset int, err error)

func (*Blockchain) GetHashrate

func (this *Blockchain) GetHashrate(blockIndex, blocksCount uint32) uint64

func (*Blockchain) GetHeight

func (this *Blockchain) GetHeight() uint32

func (*Blockchain) GetOperation

func (this *Blockchain) GetOperation(txRipemd160Hash [20]byte) (*tx.TxMetadata, tx.CommonOperation, error)

func (*Blockchain) GetState

func (this *Blockchain) GetState() (height uint32, safeboxHash []byte, cumulativeDifficulty *big.Int)

func (*Blockchain) GetTopBlock

func (b *Blockchain) GetTopBlock() (safebox.BlockBase, error)

func (*Blockchain) GetTxPool

func (b *Blockchain) GetTxPool() map[tx.CommonOperation]tx.TxMetadata

func (*Blockchain) LoadNearestSnapshot

func (this *Blockchain) LoadNearestSnapshot(targetHeight uint32) (*accounter.Accounter, error)

func (*Blockchain) LoadSnapshot

func (this *Blockchain) LoadSnapshot(height uint32) (*accounter.Accounter, error)

func (*Blockchain) ProcessNewBlock

func (b *Blockchain) ProcessNewBlock(block safebox.SerializedBlock, broadcast bool) error

func (*Blockchain) ProcessNewBlocks

func (b *Blockchain) ProcessNewBlocks(blocks []safebox.SerializedBlock, preSave *func(safebox.SafeboxBase) error) error

func (*Blockchain) SerializeBlock

func (this *Blockchain) SerializeBlock(block safebox.BlockBase) safebox.SerializedBlock

func (*Blockchain) SerializeBlockHeader

func (this *Blockchain) SerializeBlockHeader(block safebox.BlockBase, willAppendOperations bool, nullPow bool) safebox.SerializedBlockHeader

func (*Blockchain) TxPoolAddOperation

func (b *Blockchain) TxPoolAddOperation(transaction tx.CommonOperation, broadcast bool) (new bool, err error)

func (*Blockchain) UnmarshalHashingBlob

func (b *Blockchain) UnmarshalHashingBlob(blob []byte) (miner *crypto.Public, nonce uint32, timestamp uint32, payload []byte, err error)

type NewSafeboxCallback

type NewSafeboxCallback func(accounter *accounter.Accounter) safebox.SafeboxBase

Jump to

Keyboard shortcuts

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