tetris2

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: GPL-3.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const COMMITTABLE_UNDECIDED = -1
View Source
const ROUND_UNDECIDED = -1
View Source
const (
	VidStrStart = address.AddressContentIndex * 2
)

Variables

View Source
var HASH0 = [common.HashLength]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Functions

This section is empty.

Types

type DropEvent

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

type Event

type Event struct {
	Body *EventBody
	// contains filtered or unexported fields
}

func NewEvent

func NewEvent(vid string, height uint64, sequenceNumber uint64) *Event

func NewPulse

func NewPulse() *Event

func (*Event) AddParents

func (e *Event) AddParents(parents []*Event)

func (*Event) AddSelfParent

func (e *Event) AddSelfParent(selfParent *Event)

func (*Event) AddTransactions

func (e *Event) AddTransactions(txs []common.Hash)

func (*Event) Hash

func (e *Event) Hash() common.Hash

func (*Event) Marshal

func (e *Event) Marshal() []byte

func (*Event) RecoverPublicKey

func (e *Event) RecoverPublicKey(signer crypto.Signer) ([]byte, error)

func (*Event) Sign

func (e *Event) Sign(signer crypto.Signer) error

func (*Event) SignVerify

func (e *Event) SignVerify(publicKey []byte, signer crypto.Signer) bool

func (*Event) Unmarshal

func (e *Event) Unmarshal(data []byte)

type EventBody

type EventBody struct {
	H  uint64        //Block Height
	N  uint64        //Sequence Number
	T  int64         //Timestamps, unix nano, can only represent year 1678-2262
	Tx []common.Hash //Transactions List
	E  []common.Hash //Parents Events, 0 for self parent
	P  bool          //HeartBeat Pulse
}

func (*EventBody) EmptyLength

func (eb *EventBody) EmptyLength() int

func (*EventBody) Hash

func (eb *EventBody) Hash() common.Hash

func (*EventBody) Marshal

func (eb *EventBody) Marshal() ([]byte, error)

func (*EventBody) MarshalLength

func (eb *EventBody) MarshalLength() int

func (*EventBody) MarshalTo

func (eb *EventBody) MarshalTo(buf []byte) error

func (*EventBody) Unmarshal

func (eb *EventBody) Unmarshal(data []byte) error

type EventMessage

type EventMessage struct {
	Body      *EventBody
	Signature *crypto.Signature
}

func (*EventMessage) Marshal

func (em *EventMessage) Marshal() []byte

func (*EventMessage) Unmarshal

func (em *EventMessage) Unmarshal(data []byte) error

type ICore

type ICore interface {
	GetMinerSigner() (crypto.Signer, error)
	GetPrivateKeyOfDefaultAccount() ([]byte, error)
	AddressFromPublicKey(publicKey []byte) ([]byte, error)
}

type Metrics

type Metrics struct {
	TrafficIn     uint64
	TrafficOut    uint64
	EventIn       uint64
	ParentEventIn uint64
	EventOut      uint64
	EventRequest  uint64
	TxIn          uint64
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics() *Metrics

func (*Metrics) AddEventIn

func (m *Metrics) AddEventIn(num uint64)

func (*Metrics) AddEventOut

func (m *Metrics) AddEventOut(num uint64)

func (*Metrics) AddEventRequest

func (m *Metrics) AddEventRequest(num uint64)

func (*Metrics) AddParentEventIn

func (m *Metrics) AddParentEventIn(num uint64)

func (*Metrics) AddTrafficIn

func (m *Metrics) AddTrafficIn(traffic uint64)

func (*Metrics) AddTrafficOut

func (m *Metrics) AddTrafficOut(traffic uint64)

func (*Metrics) AddTxIn

func (m *Metrics) AddTxIn(num uint64)

type Params

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

type SealEvent

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

type SyncRequest

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

type Tetris

type Tetris struct {

	//Input Channel
	EventCh       chan []byte
	ParentEventCh chan []byte
	TxsCh         chan common.Hash
	SealCh        chan *SealEvent
	DropCh        chan *DropEvent

	//Output Channel
	OutputCh       chan *consensus.Output
	SendEventCh    chan []byte
	RequestEventCh chan common.Hash

	//metrics or test
	Metrics *Metrics
	// contains filtered or unexported fields
}

func NewTetris

func NewTetris(core ICore, vid string, validatorList []string, blockHeight uint64) (*Tetris, error)

func (*Tetris) ChanEventReq

func (t *Tetris) ChanEventReq() <-chan common.Hash

func (*Tetris) ChanEventSend

func (t *Tetris) ChanEventSend() <-chan []byte

func (*Tetris) DebugPrint

func (t *Tetris) DebugPrint()

Print info for debug

func (*Tetris) DebugPrintDetail

func (t *Tetris) DebugPrintDetail()

func (*Tetris) MajorityBeatReceived

func (t *Tetris) MajorityBeatReceived() bool

func (*Tetris) MajorityBeatTime

func (t *Tetris) MajorityBeatTime() (ok bool, duration time.Duration)

func (*Tetris) OnTxDropped

func (t *Tetris) OnTxDropped(txs []common.Hash)

func (*Tetris) OnTxSealed

func (t *Tetris) OnTxSealed(height uint64, txs []common.Hash)

func (*Tetris) Output

func (t *Tetris) Output() <-chan *consensus.Output

func (*Tetris) SendEvent

func (t *Tetris) SendEvent(event []byte)

func (*Tetris) SendParentEvent

func (t *Tetris) SendParentEvent(event []byte)

func (*Tetris) SendTx

func (t *Tetris) SendTx(hash common.Hash)

func (*Tetris) Start

func (t *Tetris) Start() error

func (*Tetris) Stop

func (t *Tetris) Stop() error

Jump to

Keyboard shortcuts

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