block

package
v0.0.0-...-8e17a21 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: GPL-2.0 Imports: 23 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncorrectRollbackHash = errors.New("Rollback hash doesn't match")
	ErrEmptyBlock            = errors.New("Block doesn't contain transactions")
)
View Source
var (
	ErrMaxBlockSize    = utils.WithBan(errors.New("Block size exceeds maximum limit"))
	ErrZeroBlockSize   = utils.WithBan(errors.New("Block size is zero"))
	ErrUnmarshallBlock = utils.WithBan(errors.New("Unmarshall block"))
)
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`)
)
View Source
var (
	ErrIcorrectBlockTime = utils.WithBan(errors.New("Incorrect block time"))
)

Functions

func BadTxForBan

func BadTxForBan(keyID int64)

BadTxForBan adds info about bad tx of the key

func BannedTill

func BannedTill(keyID int64) string

BannedTill returns the time that the user has been banned till

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 GetRollbacksHash

func GetRollbacksHash(transaction *model.DbTransaction, blockID int64) ([]byte, error)

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 IsKeyBanned

func IsKeyBanned(keyID int64) bool

IsBanned returns true if the key has been banned

func MarshallBlock

func MarshallBlock(header *utils.BlockData, trData [][]byte, prev *utils.BlockData, 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
	PrevRollbacksHash []byte
	MrklRoot          []byte
	BinData           []byte
	Transactions      []*transaction.Transaction
	SysUpdate         bool
	GenBlock          bool // it equals true when we are generating a new block
	Notifications     []types.Notifications
}

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, fillData 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

PlaySafe 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