fabric: github.com/hyperledger/fabric/gossip/util Index | Files

package util

import "github.com/hyperledger/fabric/gossip/util"


Package Files

grpc.go logging.go misc.go msgs.go privdata.go pubsub.go


const (
    ChannelLogger     = "gossip.channel"
    CommLogger        = "gossip.comm"
    DiscoveryLogger   = "gossip.discovery"
    ElectionLogger    = "gossip.election"
    GossipLogger      = "gossip.gossip"
    CommMockLogger    = "gossip.comm.mock"
    PullLogger        = "gossip.pull"
    ServiceLogger     = "gossip.service"
    StateLogger       = "gossip.state"
    PrivateDataLogger = "gossip.privdata"

Logger names for logger initialization.

func BytesToStrings Uses

func BytesToStrings(bytes [][]byte) []string

func Contains Uses

func Contains(s string, a []string) bool

Contains returns whether a given slice a contains a string s

func CreateGRPCLayer Uses

func CreateGRPCLayer() (port int, gRPCServer *comm.GRPCServer, certs *common.TLSCertificates,
    secureDialOpts api.PeerSecureDialOpts, dialOpts []grpc.DialOption)

CreateGRPCLayer returns a new gRPC server with associated port, TLS certificates, SecureDialOpts and DialOption

func GetDurationOrDefault Uses

func GetDurationOrDefault(key string, defVal time.Duration) time.Duration

GetDurationOrDefault returns the Duration value from config if present otherwise default value

func GetFloat64OrDefault Uses

func GetFloat64OrDefault(key string, defVal float64) float64

GetFloat64OrDefault returns the float64 value from config if present otherwise default value

func GetIntOrDefault Uses

func GetIntOrDefault(key string, defVal int) int

GetIntOrDefault returns the int value from config if present otherwise default value

func GetRandomIndices Uses

func GetRandomIndices(indiceCount, highestIndex int) []int

GetRandomIndices returns indiceCount random indices from 0 to highestIndex.

func IndexInSlice Uses

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

IndexInSlice returns the index of given object o in array, and -1 if it is not in array.

func PrintStackTrace Uses

func PrintStackTrace()

PrintStackTrace prints to stdout all goroutines

func PrivateRWSets Uses

func PrivateRWSets(rwsets ...PrivateRWSet) [][]byte

PrivateRWSets creates an aggregated slice of RWSets

func RandomInt Uses

func RandomInt(n int) int

RandomInt returns, as an int, a non-negative pseudo-random integer in [0,n) It panics if n <= 0

func RandomUInt64 Uses

func RandomUInt64() uint64

RandomUInt64 returns a random uint64

If we want a rand that's non-global and specific to gossip, we can establish one. Otherwise this uses the process-global locking RNG.

func SetVal Uses

func SetVal(key string, val interface{})

SetVal stores key value to viper

func SetupTestLogging Uses

func SetupTestLogging()

SetupTestLogging sets the default log levels for gossip unit tests to defaultTestSpec

func SetupTestLoggingWithLevel Uses

func SetupTestLoggingWithLevel(level string)

SetupTestLoggingWithLevel sets the default log levels for gossip unit tests to level

func StringsToBytes Uses

func StringsToBytes(strings []string) [][]byte

type Equals Uses

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

Equals returns whether a and b are the same

type Logger Uses

type Logger interface {
    Debug(args ...interface{})
    Debugf(format string, args ...interface{})
    Error(args ...interface{})
    Errorf(format string, args ...interface{})
    Fatal(args ...interface{})
    Fatalf(format string, args ...interface{})
    Info(args ...interface{})
    Infof(format string, args ...interface{})
    Panic(args ...interface{})
    Panicf(format string, args ...interface{})
    Warning(args ...interface{})
    Warningf(format string, args ...interface{})
    IsEnabledFor(l zapcore.Level) bool
    With(args ...interface{}) *flogging.FabricLogger

func GetLogger Uses

func GetLogger(name string, peerID string) Logger

GetLogger returns a logger for given gossip logger name and peerID

type MembershipStore Uses

type MembershipStore struct {
    // contains filtered or unexported fields

MembershipStore struct which encapsulates membership message store abstraction

func NewMembershipStore Uses

func NewMembershipStore() *MembershipStore

NewMembershipStore creates new membership store instance

func (*MembershipStore) MsgByID Uses

func (m *MembershipStore) MsgByID(pkiID common.PKIidType) *protoext.SignedGossipMessage

MsgByID returns a message stored by a certain ID, or nil if such an ID isn't found

func (*MembershipStore) Put Uses

func (m *MembershipStore) Put(pkiID common.PKIidType, msg *protoext.SignedGossipMessage)

Put associates msg with the given pkiID

func (*MembershipStore) Remove Uses

func (m *MembershipStore) Remove(pkiID common.PKIidType)

Remove removes a message with a given pkiID

func (*MembershipStore) Size Uses

func (m *MembershipStore) Size() int

Size of the membership store

func (*MembershipStore) ToSlice Uses

func (m *MembershipStore) ToSlice() []*protoext.SignedGossipMessage

ToSlice returns a slice backed by the elements of the MembershipStore

type PrivateRWSet Uses

type PrivateRWSet []byte

PrivateRWSet contains the bytes of CollectionPvtReadWriteSet

func (PrivateRWSet) Digest Uses

func (rws PrivateRWSet) Digest() string

Digest returns a deterministic and collision-free representation of the PrivateRWSet

type PrivateRWSetWithConfig Uses

type PrivateRWSetWithConfig struct {
    RWSet            []PrivateRWSet
    CollectionConfig *peer.CollectionConfig

PrivateRWSetWithConfig encapsulates private read-write set among with relevant to collections config information

type PubSub Uses

type PubSub struct {
    // contains filtered or unexported fields

PubSub 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.

func NewPubSub Uses

func NewPubSub() *PubSub

NewPubSub creates a new PubSub with an empty set of subscriptions

func (*PubSub) Publish Uses

func (ps *PubSub) Publish(topic string, item interface{}) error

Publish publishes an item to all subscribers on the topic

func (*PubSub) Subscribe Uses

func (ps *PubSub) Subscribe(topic string, ttl time.Duration) Subscription

Subscribe returns a subscription to a topic that expires when given TTL passes

type PvtDataCollections Uses

type PvtDataCollections []*ledger.TxPvtData

PvtDataCollections data type to encapsulate collections of private data

func (*PvtDataCollections) Marshal Uses

func (pvt *PvtDataCollections) Marshal() ([][]byte, error)

Marshal encodes private collection into bytes array

func (*PvtDataCollections) Unmarshal Uses

func (pvt *PvtDataCollections) Unmarshal(data [][]byte) error

Unmarshal read and unmarshal collection of private data from given bytes array

type Set Uses

type Set struct {
    // contains filtered or unexported fields

Set is a generic and thread-safe set container

func NewSet Uses

func NewSet() *Set

NewSet returns a new set

func (*Set) Add Uses

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

Add adds given item to the set

func (*Set) Clear Uses

func (s *Set) Clear()

Clear removes all elements from set

func (*Set) Exists Uses

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

Exists returns true whether given item is in the set

func (*Set) Remove Uses

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

Remove removes a given item from the set

func (*Set) Size Uses

func (s *Set) Size() int

Size returns the size of the set

func (*Set) ToArray Uses

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

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

type Subscription Uses

type Subscription interface {
    // Listen blocks until a publish was made
    // to the subscription, or an error if the
    // subscription's TTL passed
    Listen() (interface{}, error)

Subscription defines a subscription to a topic that can be used to receive publishes on

Package util imports 28 packages (graph) and is imported by 92 packages. Updated 2019-11-23. Refresh now. Tools for package owners.