protocols

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

Index

Constants

This section is empty.

Variables

View Source
var (
	WrongNodePositionError = errors.New("wrong node position")
	TimeError              = errors.New("current time before first block")
	DuplicateBlockError    = errors.New("block for this time interval exists")
)

Functions

This section is empty.

Types

type BlockTimeCalculator

type BlockTimeCalculator struct {
	// contains filtered or unexported fields
}

BlockTimeCalculator calculating block generation time

func BuildBlockTimeCalculator

func BuildBlockTimeCalculator(transaction *sqldb.DbTransaction) (BlockTimeCalculator, error)

func NewBlockTimeCalculator

func NewBlockTimeCalculator(firstBlockTime time.Time, generationTime, blocksGap time.Duration, nodesCount int64) BlockTimeCalculator

func (*BlockTimeCalculator) SetClock

func (btc *BlockTimeCalculator) SetClock(clock utils.Clock) *BlockTimeCalculator

func (*BlockTimeCalculator) TimeToGenerate

func (btc *BlockTimeCalculator) TimeToGenerate(nodePosition int64) (bool, error)

func (*BlockTimeCalculator) ValidateBlock

func (btc *BlockTimeCalculator) ValidateBlock(nodePosition int64, at time.Time) (bool, error)

type BlockTimeChecker

type BlockTimeChecker interface {
	TimeToGenerate(position int64) (bool, error)
	BlockForTimeExists(t time.Time, nodePosition int) (bool, error)
	RangeByTime(at time.Time) (start, end time.Time, err error)
}

BlockTimeChecker allow check queue to generate current block

type BlockTimeCounter

type BlockTimeCounter struct {
	// contains filtered or unexported fields
}

func NewBlockTimeCounter

func NewBlockTimeCounter() *BlockTimeCounter

NewBlockTimeCounter return initialized BlockTimeCounter

func (*BlockTimeCounter) BlockForTimeExists

func (btc *BlockTimeCounter) BlockForTimeExists(t time.Time, nodePosition int) (bool, error)

BlockForTimeExists checks conformity between time and nodePosition changes functionality of ValidateBlock prevent blockTimeCalculator

func (*BlockTimeCounter) NodeTimeExists

func (btc *BlockTimeCounter) NodeTimeExists(t time.Time, nodePosition int) (bool, error)

func (*BlockTimeCounter) RangeByTime

func (btc *BlockTimeCounter) RangeByTime(t time.Time) (start, end time.Time, err error)

RangeByTime returns start and end of interval by time

func (*BlockTimeCounter) TimeToGenerate

func (btc *BlockTimeCounter) TimeToGenerate(at time.Time, nodePosition int) (bool, error)

TimeToGenerate returns true if the generation queue at time belongs to the specified node

Jump to

Keyboard shortcuts

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