block

package
v0.0.0-...-5ecede5 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: LGPL-3.0-or-later Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLimitSkip returns when tx should be skipped during generating block
	ErrLimitSkip = errors.New(`skip tx`)
	// ErrLimitStop returns when the generation of the block should be stopped
	ErrLimitStop = errors.New(`stop generating block`)
	// ErrLimitTime returns when the time limit exceeded
	ErrLimitTime = errors.New(`Time limit exceeded`)
)

Functions

func GetBlockDataFromBlockChain

func GetBlockDataFromBlockChain(blockID int64) (*utils.BlockData, error)

GetBlockDataFromBlockChain is retrieving block data from blockchain

func GetDataFromFirstBlock

func GetDataFromFirstBlock() (data *consts.FirstBlock, ok bool)

GetDataFromFirstBlock returns data of first block

func InsertBlockWOForks

func InsertBlockWOForks(data []byte, genBlock, firstBlock bool) error

InsertBlockWOForks is inserting blocks

func InsertIntoBlockchain

func InsertIntoBlockchain(transaction *model.DbTransaction, block *Block) error

InsertIntoBlockchain inserts a block into the blockchain

func MarshallBlock

func MarshallBlock(header *utils.BlockData, trData [][]byte, prevHash []byte, key string) ([]byte, error)

MarshallBlock is marshalling block

func UpdBlockInfo

func UpdBlockInfo(dbTransaction *model.DbTransaction, block *Block) error

UpdBlockInfo updates info_block table

Types

type Block

type Block struct {
	Header       utils.BlockData
	PrevHeader   *utils.BlockData
	MrklRoot     []byte
	BinData      []byte
	Transactions []*transaction.Transaction
	SysUpdate    bool
	GenBlock     bool // it equals true when we are generating a new block
	StopCount    int  // The count of good tx in the block
}

Block is storing block data

func ProcessBlockWherePrevFromBlockchainTable

func ProcessBlockWherePrevFromBlockchainTable(data []byte, checkSize bool) (*Block, error)

ProcessBlockWherePrevFromBlockchainTable is processing block with in table previous block

func UnmarshallBlock

func UnmarshallBlock(blockBuffer *bytes.Buffer, firstBlock bool) (*Block, error)

func (*Block) Check

func (b *Block) Check() error

CheckBlock is checking block

func (*Block) CheckHash

func (b *Block) CheckHash() (bool, error)

CheckHash is checking hash

func (Block) GetLogger

func (b Block) GetLogger() *log.Entry

GetLogger is returns logger

func (*Block) Play

func (b *Block) Play(dbTransaction *model.DbTransaction) error

func (*Block) PlaySafe

func (b *Block) PlaySafe() error

PlayBlockSafe is inserting block safely

func (Block) String

func (b Block) String() string

type Limiter

type Limiter interface {
	// contains filtered or unexported methods
}

Limiter describes interface functions for limits

type Limits

type Limits struct {
	Mode     int
	Block    *Block    // it equals nil if checking before generatin block
	Limiters []Limiter // the list of limiters
}

Limits is used for saving current limit information

func NewLimits

func NewLimits(b *Block) (limits *Limits)

NewLimits initializes Limits structure.

func (*Limits) CheckLimit

func (limits *Limits) CheckLimit(t *transaction.Transaction) error

CheckLimit calls each limiter

Jump to

Keyboard shortcuts

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