{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package util\n\n## Constants\n\n```go\nconst (\n\tChannelLogger     = \"gossip.channel\"\n\tCommLogger        = \"gossip.comm\"\n\tDiscoveryLogger   = \"gossip.discovery\"\n\tElectionLogger    = \"gossip.election\"\n\tGossipLogger      = \"gossip.gossip\"\n\tCommMockLogger    = \"gossip.comm.mock\"\n\tPullLogger        = \"gossip.pull\"\n\tServiceLogger     = \"gossip.service\"\n\tStateLogger       = \"gossip.state\"\n\tPrivateDataLogger = \"gossip.privdata\"\n)\n```\nLogger names for logger initialization.\n\n## Functions\n\n```go\nfunc BytesToStrings(bytes [][]byte) []string\n```\n\n```go\nfunc Contains(s string, a []string) bool\n```\nContains returns whether a given slice a contains a string s\n\n```go\nfunc CreateGRPCLayer() (port int, gRPCServer *comm.GRPCServer, certs *common.TLSCertificates,\n\tsecureDialOpts api.PeerSecureDialOpts, dialOpts []grpc.DialOption)\n```\nCreateGRPCLayer returns a new gRPC server with associated port, TLS certificates, SecureDialOpts and DialOption\n\n```go\nfunc GetDurationOrDefault(key string, defVal time.Duration) time.Duration\n```\nGetDurationOrDefault returns the Duration value from config if present otherwise default value\n\n```go\nfunc GetFloat64OrDefault(key string, defVal float64) float64\n```\nGetFloat64OrDefault returns the float64 value from config if present otherwise default value\n\n```go\nfunc GetIntOrDefault(key string, defVal int) int\n```\nGetIntOrDefault returns the int value from config if present otherwise default value\n\n```go\nfunc GetRandomIndices(indiceCount, highestIndex int) []int\n```\nGetRandomIndices returns a slice of random indices from 0 to given highestIndex\n\n```go\nfunc IndexInSlice(array interface{}, o interface{}, equals Equals) int\n```\nIndexInSlice returns the index of given object o in array\n\n```go\nfunc PrintStackTrace()\n```\nPrintStackTrace prints to stdout all goroutines\n\n```go\nfunc PrivateRWSets(rwsets ...PrivateRWSet) [][]byte\n```\nPrivateRWSets creates an aggregated slice of RWSets\n\n```go\nfunc RandomInt(n int) int\n```\nRandomInt returns, as an int, a non-negative pseudo-random integer in \\[0,n) It panics if n \\\u003c= 0\n\n```go\nfunc RandomUInt64() uint64\n```\nRandomUInt64 returns a random uint64\n\n```go\nfunc SetVal(key string, val interface{})\n```\nSetVal stores key value to viper\n\n```go\nfunc SetupTestLogging()\n```\nSetupTestLogging sets the default log levels for gossip unit tests\n\n```go\nfunc StringsToBytes(strings []string) [][]byte\n```\n\n## Types\n\n```go\ntype Equals func(a interface{}, b interface{}) bool\n```\nEquals returns whether a and b are the same\n\n```go\ntype Logger interface {\n\tDebug(args ...interface{})\n\tDebugf(format string, args ...interface{})\n\tError(args ...interface{})\n\tErrorf(format string, args ...interface{})\n\tFatal(args ...interface{})\n\tFatalf(format string, args ...interface{})\n\tInfo(args ...interface{})\n\tInfof(format string, args ...interface{})\n\tPanic(args ...interface{})\n\tPanicf(format string, args ...interface{})\n\tWarning(args ...interface{})\n\tWarningf(format string, args ...interface{})\n\tIsEnabledFor(l zapcore.Level) bool\n}\n```\n\n```go\nfunc GetLogger(name string, peerID string) Logger\n```\nGetLogger returns a logger for given gossip logger name and peerID\n\n```go\ntype MembershipStore struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nMembershipStore struct which encapsulates membership message store abstraction\n\n```go\nfunc NewMembershipStore() *MembershipStore\n```\nNewMembershipStore creates new membership store instance\n\n```go\nfunc (m *MembershipStore) MsgByID(pkiID common.PKIidType) *proto.SignedGossipMessage\n```\nMsgByID returns a message stored by a certain ID, or nil if such an ID isn't found\n\n```go\nfunc (m *MembershipStore) Put(pkiID common.PKIidType, msg *proto.SignedGossipMessage)\n```\nPut associates msg with the given pkiID\n\n```go\nfunc (m *MembershipStore) Remove(pkiID common.PKIidType)\n```\nRemove removes a message with a given pkiID\n\n```go\nfunc (m *MembershipStore) Size() int\n```\nSize of the membership store\n\n```go\nfunc (m *MembershipStore) ToSlice() []*proto.SignedGossipMessage\n```\nToSlice returns a slice backed by the elements of the MembershipStore\n\n```go\ntype PrivateRWSet []byte\n```\nPrivateRWSet contains the bytes of CollectionPvtReadWriteSet\n\n```go\nfunc (rws PrivateRWSet) Digest() string\n```\nDigest returns a deterministic and collision-free representation of the PrivateRWSet\n\n```go\ntype PrivateRWSetWithConfig struct {\n\tRWSet            []PrivateRWSet\n\tCollectionConfig *common.CollectionConfig\n}\n```\nPrivateRWSetWithConfig encapsulates private read-write set among with relevant to collections config information\n\n```go\ntype PubSub struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nPubSub defines a struct that one can use to: - publish items to a topic to multiple subscribers - and subscribe to items from a topic The subscriptions have a TTL and are cleaned when it passes.\n\n```go\nfunc NewPubSub() *PubSub\n```\nNewPubSub creates a new PubSub with an empty set of subscriptions\n\n```go\nfunc (ps *PubSub) Publish(topic string, item interface{}) error\n```\nPublish publishes an item to all subscribers on the topic\n\n```go\nfunc (ps *PubSub) Subscribe(topic string, ttl time.Duration) Subscription\n```\nSubscribe returns a subscription to a topic that expires when given TTL passes\n\n```go\ntype PvtDataCollections []*ledger.TxPvtData\n```\nPvtDataCollections data type to encapsulate collections of private data\n\n```go\nfunc (pvt *PvtDataCollections) Marshal() ([][]byte, error)\n```\nMarshal encodes private collection into bytes array\n\n```go\nfunc (pvt *PvtDataCollections) Unmarshal(data [][]byte) error\n```\nUnmarshal read and unmarshal collection of private data from given bytes array\n\n```go\ntype Set struct {\n\t// contains filtered or unexported fields\n}\n```\nSet is a generic and thread-safe set container\n\n```go\nfunc NewSet() *Set\n```\nNewSet returns a new set\n\n```go\nfunc (s *Set) Add(item interface{})\n```\nAdd adds given item to the set\n\n```go\nfunc (s *Set) Clear()\n```\nClear removes all elements from set\n\n```go\nfunc (s *Set) Exists(item interface{}) bool\n```\nExists returns true whether given item is in the set\n\n```go\nfunc (s *Set) Remove(item interface{})\n```\nRemove removes a given item from the set\n\n```go\nfunc (s *Set) Size() int\n```\nSize returns the size of the set\n\n```go\nfunc (s *Set) ToArray() []interface{}\n```\nToArray returns a slice with items at the point in time the method was invoked\n\n```go\ntype Subscription interface {\n\t// Listen blocks until a publish was made\n\t// to the subscription, or an error if the\n\t// subscription's TTL passed\n\tListen() (interface{}, error)\n}\n```\nSubscription defines a subscription to a topic that can be used to receive publishes on\n\n","path":"github.com/eric-erki/https-hyperledger.org/gossip/util","name":"util","synopsis":"","isRedistributable":true}
