util

package
v1.0.0-preview Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: Apache-2.0 Imports: 10 Imported by: 3,596

Documentation

Index

Constants

View Source
const (
	// LoggingMessageBuffModule defines the module for logging message buffer
	LoggingMessageBuffModule = "mbuff"
	// LoggingEmitterModule defines the module for logging emitter
	LoggingEmitterModule = "emitter"
	// LoggingGossipModule defines the module for logging gossip
	LoggingGossipModule = "gossip"
	// LoggingDiscoveryModule defines the module for logging discovery
	LoggingDiscoveryModule = "discovery"
	// LoggingCommModule defines the module for logging communication
	LoggingCommModule = "comm"
)

Variables

This section is empty.

Functions

func Abs

func Abs(a, b uint64) uint64

Abs returns abs(a-b)

func GetRandomIndices

func GetRandomIndices(indiceCount, highestIndex int) []int

GetRandomIndices returns a slice of random indices from 0 to given highestIndex

func IndexInSlice

func IndexInSlice(array interface{}, o interface{}, equals Equals) int

IndexInSlice returns the index of given object o in array

func PrintStackTrace

func PrintStackTrace()

PrintStackTrace prints to stdout all goroutines

func SetDefaultFormat

func SetDefaultFormat(formatStr string)

SetDefaultFormat sets the formatter for the gossip logger

func SetDefaultLoggingLevel

func SetDefaultLoggingLevel(level logging.Level)

SetDefaultLoggingLevel sets the default logging level for the gossip logger

Types

type Equals

type Equals func(a interface{}, b interface{}) bool

Equals returns whether a and b are the same

type Logger added in v1.3.0

type Logger struct {
	logging.Logger
	// contains filtered or unexported fields
}

Logger defines a logger for gossip

func GetLogger

func GetLogger(module string, peerID string) *Logger

GetLogger returns a logger for given gossip module and peerID

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl logging.Level)

SetLevel sets the level for the logger

type Set

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

Set is a generic and thread-safe set container

func NewSet

func NewSet() *Set

NewSet returns a new set

func (*Set) Add

func (s *Set) Add(item interface{})

Add adds given item to the set

func (*Set) Clear

func (s *Set) Clear()

Clear removes all elements from set

func (*Set) Exists

func (s *Set) Exists(item interface{}) bool

Exists returns true whether given item is in the set

func (*Set) Remove

func (s *Set) Remove(item interface{})

Remove removes a given item from the set

func (*Set) ToArray

func (s *Set) ToArray() []interface{}

ToArray returns a slice with items at the point in time the method was invoked

Jump to

Keyboard shortcuts

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