Documentation ¶
Index ¶
- Variables
- func CallMethod(i interface{}, methodName string) interface{}
- func Caller(steps int) string
- func CheckSign(publicKeys [][]byte, forSign []byte, signs []byte, nodeKeyOrLogin bool) (bool, error)
- func CopyFileContents(src, dst string) error
- func CreateDirIfNotExists(dir string, mode os.FileMode) error
- func ErrInfo(verr interface{}, additionally ...string) error
- func ErrInfoFmt(err string, a ...interface{}) error
- func GetCurrentDir() string
- func GetHTTPTextAnswer(url string) (string, error)
- func GetHostPort(h string) string
- func GetNodeKeys() (string, string, error)
- func GetNodePrivateKey() ([]byte, error)
- func GetParent() string
- func IsBanError(err error) bool
- func LockOrDie(dir string) *flock.Flock
- func MakeDirectory(dir string) error
- func MerkleTreeRoot(dataArray [][]byte) []byte
- func ShellExecute(cmdline string)
- func ShuffleSlice(slice []string)
- func StringInSlice(slice []string, v string) bool
- func TypeInt(txType string) int64
- func UUID() string
- func WithBan(err error) error
- type BanError
- type BlockData
- type BlockTimeCalculator
- type BlockTimeCounter
- func (btc *BlockTimeCounter) Block(t time.Time) int
- func (btc *BlockTimeCounter) BlockForTimeExists(t time.Time, nodePosition int) (bool, error)
- func (btc *BlockTimeCounter) NextTime(t time.Time, nodePosition int) time.Time
- func (btc *BlockTimeCounter) NodePosition(t time.Time) int
- func (btc *BlockTimeCounter) RangesByTime(t time.Time) (start, end time.Time)
- func (btc *BlockTimeCounter) ValidateBlock(t time.Time, nodePosition int) bool
- type Cert
- type Clock
- type ClockWrapper
- type MockClock
- type Rand
Constants ¶
This section is empty.
Variables ¶
var ( // ReturnCh is chan for returns ReturnCh chan string // CancelFunc is represents cancel func CancelFunc context.CancelFunc // DaemonsCount is number of daemons DaemonsCount int )
var DuplicateBlockError = errors.New("block with that time interval already exists in db")
var ErrBlockSize = errors.New("Bad block size")
var TimeError = errors.New("current time before first block")
Functions ¶
func CallMethod ¶
func CallMethod(i interface{}, methodName string) interface{}
CallMethod calls the function by its name
func CheckSign ¶
func CheckSign(publicKeys [][]byte, forSign []byte, signs []byte, nodeKeyOrLogin bool) (bool, error)
CheckSign checks the signature
func ErrInfoFmt ¶
ErrInfoFmt fomats the error message
func GetHTTPTextAnswer ¶
GetHTTPTextAnswer returns HTTP answer as a string
func GetHostPort ¶
func GetNodeKeys ¶
GetNodeKeys returns node private key and public key
func GetNodePrivateKey ¶
func GetParent ¶
func GetParent() string
GetParent returns the information where the call of function happened
func IsBanError ¶
func MakeDirectory ¶
MakeDirectory makes directory if is not exists
func MerkleTreeRoot ¶
MerkleTreeRoot rertun Merkle value
func ShuffleSlice ¶
func ShuffleSlice(slice []string)
func StringInSlice ¶
Types ¶
type BlockData ¶
type BlockData struct { BlockID int64 Time int64 EcosystemID int64 KeyID int64 NodePosition int64 Sign []byte Hash []byte RollbacksHash []byte Version int PrivateBlockchain bool }
BlockData is a structure of the block's header
func ParseBlockHeader ¶
ParseBlockHeader is parses block header
type BlockTimeCalculator ¶
type BlockTimeCalculator struct {
// contains filtered or unexported fields
}
BlockTimeCalculator calculating block generation time
func BuildBlockTimeCalculator ¶
func BuildBlockTimeCalculator(transaction *model.DbTransaction) (BlockTimeCalculator, error)
func NewBlockTimeCalculator ¶
func (*BlockTimeCalculator) SetClock ¶
func (btc *BlockTimeCalculator) SetClock(clock Clock) *BlockTimeCalculator
func (*BlockTimeCalculator) TimeToGenerate ¶
func (btc *BlockTimeCalculator) TimeToGenerate(nodePosition int64) (bool, error)
func (*BlockTimeCalculator) ValidateBlock ¶
type BlockTimeCounter ¶
type BlockTimeCounter struct {
// contains filtered or unexported fields
}
func NewBlockTimeCounter ¶
func NewBlockTimeCounter() *BlockTimeCounter
NewBlockTimeCounter return initialized BlockTimeCounter
func (*BlockTimeCounter) Block ¶
func (btc *BlockTimeCounter) Block(t time.Time) int
Block returns serial block number for time
func (*BlockTimeCounter) BlockForTimeExists ¶
func (*BlockTimeCounter) NodePosition ¶
func (btc *BlockTimeCounter) NodePosition(t time.Time) int
NodePosition returns generating node position for time
func (*BlockTimeCounter) RangesByTime ¶
func (btc *BlockTimeCounter) RangesByTime(t time.Time) (start, end time.Time)
RangesByTime returns start and end of interval by time
func (*BlockTimeCounter) ValidateBlock ¶
func (btc *BlockTimeCounter) ValidateBlock(t time.Time, nodePosition int) bool
ValidateBlock checks conformity between time and nodePosition
type Cert ¶
type Cert struct {
// contains filtered or unexported fields
}