Documentation ¶
Index ¶
- Constants
- Variables
- type Event
- type Events
- type EventsSlice
- 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) Generate(rand *rand.Rand, size int) reflect.Value
- func (h Hash) Hex() string
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) Scan(src interface{}) error
- func (h *Hash) SetBytes(raw []byte)
- func (h Hash) ShortString() string
- 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 Peer
- type Transaction
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = sha256.Size )
Variables ¶
var EmptyPeer = Peer{}
EmptyPeer is empty peer identifier.
var ( // EventNameDict is an optional dictionary to make events human readable in log. EventNameDict = make(map[Event]string) )
var ( // NodeNameDict is an optional dictionary to make node address human readable in log. NodeNameDict = make(map[Peer]string) )
var ( // ZeroEvent is a hash of virtual initial event. ZeroEvent = Event{} )
var ( // ZeroTransaction is a hash of virtual initial transaction. ZeroTransaction = Transaction{} )
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event Hash
Event is a unique identifier of event. It is a hash of Event.
func BytesToEventHash ¶
BytesToEventHash 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 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.
type Events ¶
type Events map[Event]struct{}
Events provides additional methods of event hash index.
func FakeEvents ¶
FakeEvents generates random fake event hashes for testing purpose.
func WireToEventHashes ¶
WireToEventHashes converts from simple slice.
type EventsSlice ¶
type EventsSlice []Event
EventsSlice is a sortable slice of event hash.
func WireToEventHashSlice ¶
func WireToEventHashSlice(buf [][]byte) EventsSlice
WireToEventHashSlice converts from simple slice.
func (EventsSlice) Len ¶
func (hh EventsSlice) Len() int
func (EventsSlice) Less ¶
func (hh EventsSlice) Less(i, j int) bool
func (EventsSlice) Swap ¶
func (hh EventsSlice) Swap(i, j int)
func (EventsSlice) ToWire ¶
func (hh EventsSlice) ToWire() [][]byte
ToWire converts to simple slice.
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 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 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 converts bytes to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) ShortString ¶
ShortString returns short string representation.
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 Peer ¶
type Peer Hash
Peer is a unique peer identifier. It is a hash of peer's PubKey.
func BytesToPeer ¶
BytesToPeer converts bytes to peer id. If b is larger than len(h), b will be cropped from the left.
func HexToPeer ¶
HexToPeer sets byte representation of s to peer id. If b is larger than len(h), b will be cropped from the left.
func PeerOfPubkey ¶
PeerOfPubkey calcs peer id from pub key.
func PeerOfPubkeyBytes ¶
PeerOfPubkeyBytes calcs peer id from pub key bytes.
type Transaction ¶
type Transaction Hash
Transaction is a unique identifier of internal transaction. It is a hash of Transaction.
func FakeTransaction ¶
func FakeTransaction() Transaction
FakeTransaction generates random fake hash for testing purpose.
func HexToTransactionHash ¶
func HexToTransactionHash(s string) Transaction
HexToTransactionHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (Transaction) Hex ¶
func (h Transaction) Hex() string
Hex converts an event hash to a hex string.
func (*Transaction) IsZero ¶
func (h *Transaction) IsZero() bool
IsZero returns true if hash is empty.