statement

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0, BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConflictLength defines the Conflict length in bytes.
	ConflictLength = ledgerstate.TransactionIDLength + OpinionLength
)
View Source
const (
	// ObjectName defines the name of the Statement object.
	ObjectName = "Statement"
)
View Source
const (
	// OpinionLength defines the opinion length in bytes.
	OpinionLength = 2
)
View Source
const (
	// TimestampLength defines the Timestamp length in bytes.
	TimestampLength = tangle.MessageIDLength + OpinionLength
)

Variables

View Source
var StatementType payload.Type

StatementType represents the payload Type of a Statement.

Functions

This section is empty.

Types

type Conflict

type Conflict struct {
	ID ledgerstate.TransactionID
	Opinion
}

Conflict holds the conflicting transaction ID and its opinion.

func ConflictFromBytes

func ConflictFromBytes(bytes []byte) (conflict Conflict, consumedBytes int, err error)

ConflictFromBytes parses a conflict statement from a byte slice.

func ConflictFromMarshalUtil

func ConflictFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (conflict Conflict, err error)

ConflictFromMarshalUtil is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.

func (Conflict) Bytes

func (c Conflict) Bytes() (bytes []byte)

Bytes returns the conflict statement encoded as bytes.

func (Conflict) String

func (c Conflict) String() string

String returns a human readable version of the Conflict.

type Conflicts

type Conflicts []Conflict

Conflicts is a slice of Conflict.

func ConflictsFromBytes

func ConflictsFromBytes(bytes []byte, n uint32) (conflicts Conflicts, consumedBytes int, err error)

ConflictsFromBytes parses a slice of conflict statements from a byte slice.

func ConflictsFromMarshalUtil

func ConflictsFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil, n uint32) (conflicts Conflicts, err error)

ConflictsFromMarshalUtil is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.

func (Conflicts) Bytes

func (c Conflicts) Bytes() (bytes []byte)

Bytes returns the conflicts statements encoded as bytes.

func (Conflicts) String

func (c Conflicts) String() string

String returns a human readable version of the Conflicts.

type Entry

type Entry struct {
	Opinions
	Timestamp time.Time
}

Entry defines the entry of a registry.

type Opinion

type Opinion struct {
	Value opinion.Opinion
	Round uint8
}

Opinion holds the opinion at a specific round.

func OpinionFromBytes

func OpinionFromBytes(bytes []byte) (opinion Opinion, consumedBytes int, err error)

OpinionFromBytes parses an opinion from a byte slice.

func OpinionFromMarshalUtil

func OpinionFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result Opinion, err error)

OpinionFromMarshalUtil is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.

func (Opinion) Bytes

func (o Opinion) Bytes() (bytes []byte)

Bytes returns a marshaled version of the opinion.

func (Opinion) String

func (o Opinion) String() string

String returns a human readable version of the Opinion.

type Opinions

type Opinions []Opinion

Opinions is a slice of Opinion.

func (Opinions) Finalized

func (o Opinions) Finalized(l int) bool

Finalized returns true if the given opinion has been finalized.

func (Opinions) Last

func (o Opinions) Last() Opinion

Last returns the opinion of the last round.

func (Opinions) Len

func (o Opinions) Len() int

func (Opinions) Less

func (o Opinions) Less(i, j int) bool

func (Opinions) Swap

func (o Opinions) Swap(i, j int)

type Registry

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

Registry holds the opinions of all the nodes.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a new registry.

func (*Registry) Clean

func (r *Registry) Clean(d time.Duration)

Clean deletes all the entries older than the given duration d.

func (*Registry) NodeView

func (r *Registry) NodeView(id identity.ID) *View

NodeView returns the view of the given node, and adds a new view if not present.

func (*Registry) NodesView

func (r *Registry) NodesView() []*View

NodesView returns a slice of the views of all nodes.

type Statement

type Statement struct {
	ConflictsCount  uint32
	Conflicts       Conflicts
	TimestampsCount uint32
	Timestamps      Timestamps
	// contains filtered or unexported fields
}

Statement defines a Statement payload.

func FromBytes

func FromBytes(bytes []byte) (statement *Statement, consumedBytes int, err error)

FromBytes unmarshals a Statement Payload from a sequence of bytes.

func New

func New(conflicts Conflicts, timestamps Timestamps) *Statement

New creates a new Statement payload.

func Parse

func Parse(marshalUtil *marshalutil.MarshalUtil) (statement *Statement, err error)

Parse unmarshals a statement using the given marshalUtil (for easier marshaling/unmarshaling).

func (*Statement) Bytes

func (s *Statement) Bytes() (bytes []byte)

Bytes returns the statement payload bytes.

func (*Statement) Marshal

func (s *Statement) Marshal() (bytes []byte, err error)

Marshal marshals the statement payload into bytes.

func (*Statement) String

func (s *Statement) String() string

func (*Statement) Type

func (*Statement) Type() payload.Type

Type returns the type of the statement payload.

type Timestamp

type Timestamp struct {
	ID tangle.MessageID
	Opinion
}

Timestamp holds the message ID and its timestamp opinion.

func TimestampFromBytes

func TimestampFromBytes(bytes []byte) (timestamp Timestamp, consumedBytes int, err error)

TimestampFromBytes parses a conflict statement from a byte slice.

func TimestampFromMarshalUtil

func TimestampFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (timestamp Timestamp, err error)

TimestampFromMarshalUtil is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.

func (Timestamp) Bytes

func (t Timestamp) Bytes() (bytes []byte)

Bytes returns the timestamp statement encoded as bytes.

func (Timestamp) String

func (t Timestamp) String() string

String returns a human readable version of the Conflict.

type Timestamps

type Timestamps []Timestamp

Timestamps is a slice of Timestamp.

func TimestampsFromBytes

func TimestampsFromBytes(bytes []byte, n uint32) (timestamps Timestamps, consumedBytes int, err error)

TimestampsFromBytes parses a slice of timestamp statements from a byte slice.

func TimestampsFromMarshalUtil

func TimestampsFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil, n uint32) (timestamps Timestamps, err error)

TimestampsFromMarshalUtil is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.

func (Timestamps) Bytes

func (t Timestamps) Bytes() (bytes []byte)

Bytes returns the timestamps statements encoded as bytes.

func (Timestamps) String

func (t Timestamps) String() string

String returns a human readable version of the Timestamps.

type View

type View struct {
	NodeID    identity.ID
	Conflicts map[ledgerstate.TransactionID]Entry

	Timestamps map[tangle.MessageID]Entry

	LastStatementReceivedTimestamp time.Time
	// contains filtered or unexported fields
}

View holds the node's opinion about conflicts and timestamps.

func (*View) AddConflict

func (v *View) AddConflict(c Conflict)

AddConflict appends the given conflict to the given view.

func (*View) AddConflicts

func (v *View) AddConflicts(conflicts Conflicts)

AddConflicts appends the given conflicts to the given view.

func (*View) AddTimestamp

func (v *View) AddTimestamp(t Timestamp)

AddTimestamp appends the given timestamp to the given view.

func (*View) AddTimestamps

func (v *View) AddTimestamps(timestamps Timestamps)

AddTimestamps appends the given timestamps to the given view.

func (*View) ConflictOpinion

func (v *View) ConflictOpinion(id ledgerstate.TransactionID) Opinions

ConflictOpinion returns the opinion history of a given transaction ID.

func (*View) ID

func (v *View) ID() identity.ID

ID returns the nodeID of the given view.

func (*View) Query

func (v *View) Query(ctx context.Context, conflictIDs []string, timestampIDs []string) (opinion.Opinions, error)

Query retrieves the opinions about the given conflicts and timestamps.

func (*View) TimestampOpinion

func (v *View) TimestampOpinion(id tangle.MessageID) Opinions

TimestampOpinion returns the opinion history of a given message ID.

func (*View) UpdateLastStatementReceivedTime added in v0.5.5

func (v *View) UpdateLastStatementReceivedTime(statementReceivingTime time.Time)

UpdateLastStatementReceivedTime updates last statement issuing time in node's View.

Jump to

Keyboard shortcuts

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