Documentation ¶
Index ¶
- Constants
- Variables
- func FakeEpoch() idx.Epoch
- func FakeHash(seed ...int64) (h common.Hash)
- func FakePeer(seed ...int64) idx.ValidatorID
- func GetEventName(e Event) string
- func GetNodeName(n idx.ValidatorID) string
- func SetEventName(e Event, name string)
- func SetNodeName(n idx.ValidatorID, name string)
- type Event
- func (h *Event) Big() *big.Int
- func (h Event) Bytes() []byte
- func (h Event) Epoch() idx.Epoch
- func (h Event) FullID() string
- func (h Event) Hex() string
- func (h *Event) IsZero() bool
- func (h Event) Lamport() idx.Lamport
- func (h *Event) SetBytes(raw []byte)
- func (h Event) ShortID(precision int) string
- func (h Event) String() string
- type Events
- type EventsSet
- type EventsStack
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Hex() string
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) SetBytes(b []byte)
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalJSON(input []byte) error
- func (h *Hash) UnmarshalText(input []byte) error
- type Hashes
- type HashesSet
- type OrderedEvents
Constants ¶
const (
// HashLength is the expected length of the hash
HashLength = 32
)
Variables ¶
var ( // Zero is an empty hash. Zero = Hash{} )
var ( // ZeroEvent is a hash of virtual initial event. ZeroEvent = Event{} )
Functions ¶
func FakePeer ¶
func FakePeer(seed ...int64) idx.ValidatorID
FakePeer generates random fake peer id for testing purpose.
func GetEventName ¶
GetEventName gets an optional human readable alias of event hash.
func GetNodeName ¶
func GetNodeName(n idx.ValidatorID) string
GetNodeName gets an optional human readable alias of node address.
func SetEventName ¶
SetEventName sets an optional human readable alias of event hash in log.
func SetNodeName ¶
func SetNodeName(n idx.ValidatorID, name string)
SetNodeName sets an optional human readable alias of node address in log.
Types ¶
type Event ¶
type Event Hash
Event is a unique identifier of event. It is a hash of Event.
func BytesToEvent ¶
BytesToEvent converts bytes to event hash. If b is larger than len(h), b will be cropped from the left.
func FakeEvent ¶
func FakeEvent() (h Event)
FakeEvent generates random fake event hash with the same epoch for testing purpose.
func HexToEventHash ¶
HexToEventHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (*Event) SetBytes ¶
setBytes converts bytes to event hash. If b is larger than len(h), b will be cropped from the left.
type Events ¶
type Events []Event
Events is a slice of event hashes.
func FakeEvents ¶
FakeEvents generates random hashes of fake event with the same epoch for testing purpose.
type EventsSet ¶
type EventsSet map[Event]struct{}
EventsSet provides additional methods of event hash index.
type EventsStack ¶
type EventsStack []Event
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte hash of arbitrary data.
func BigToHash ¶
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func FromBytes ¶
FromBytes converts bytes to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) SetBytes ¶
setBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type HashesSet ¶
type HashesSet map[Hash]struct{}
type OrderedEvents ¶
type OrderedEvents []Event
OrderedEvents is a sortable slice of event hashes.
func (OrderedEvents) ByEpochAndLamport ¶
func (hh OrderedEvents) ByEpochAndLamport()
ByEpochAndLamport sorts events by epoch first, by lamport second, by ID third
func (OrderedEvents) Len ¶
func (hh OrderedEvents) Len() int
func (OrderedEvents) Less ¶
func (hh OrderedEvents) Less(i, j int) bool
func (OrderedEvents) String ¶
func (hh OrderedEvents) String() string
String returns string representation.
func (OrderedEvents) Swap ¶
func (hh OrderedEvents) Swap(i, j int)