...

Package util

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

Overview ▾

Index ▾

Constants
func BytesToStrings(bytes [][]byte) []string
func Contains(s string, a []string) bool
func CreateGRPCLayer() (port int, gRPCServer *comm.GRPCServer, certs *common.TLSCertificates, secureDialOpts api.PeerSecureDialOpts, dialOpts []grpc.DialOption)
func GetDurationOrDefault(key string, defVal time.Duration) time.Duration
func GetFloat64OrDefault(key string, defVal float64) float64
func GetIntOrDefault(key string, defVal int) int
func GetRandomIndices(indiceCount, highestIndex int) []int
func IndexInSlice(array interface{}, o interface{}, equals Equals) int
func PrintStackTrace()
func PrivateRWSets(rwsets ...PrivateRWSet) [][]byte
func RandomInt(n int) int
func RandomUInt64() uint64
func SetVal(key string, val interface{})
func SetupTestLogging()
func StringsToBytes(strings []string) [][]byte
type Equals
type Logger
    func GetLogger(name string, peerID string) Logger
type MembershipStore
    func NewMembershipStore() *MembershipStore
    func (m *MembershipStore) MsgByID(pkiID common.PKIidType) *proto.SignedGossipMessage
    func (m *MembershipStore) Put(pkiID common.PKIidType, msg *proto.SignedGossipMessage)
    func (m *MembershipStore) Remove(pkiID common.PKIidType)
    func (m *MembershipStore) Size() int
    func (m *MembershipStore) ToSlice() []*proto.SignedGossipMessage
type PrivateRWSet
    func (rws PrivateRWSet) Digest() string
type PrivateRWSetWithConfig
type PubSub
    func NewPubSub() *PubSub
    func (ps *PubSub) Publish(topic string, item interface{}) error
    func (ps *PubSub) Subscribe(topic string, ttl time.Duration) Subscription
type PvtDataCollections
    func (pvt *PvtDataCollections) Marshal() ([][]byte, error)
    func (pvt *PvtDataCollections) Unmarshal(data [][]byte) error
type Set
    func NewSet() *Set
    func (s *Set) Add(item interface{})
    func (s *Set) Clear()
    func (s *Set) Exists(item interface{}) bool
    func (s *Set) Remove(item interface{})
    func (s *Set) Size() int
    func (s *Set) ToArray() []interface{}
type Subscription

Package files

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

Constants

Logger names for logger initialization.

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"
)

func BytesToStrings

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

func Contains

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

Contains returns whether a given slice a contains a string s

func CreateGRPCLayer

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

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

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

func GetFloat64OrDefault

func GetFloat64OrDefault(key string, defVal float64) float64

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

func GetIntOrDefault

func GetIntOrDefault(key string, defVal int) int

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

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 PrivateRWSets

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

PrivateRWSets creates an aggregated slice of RWSets

func RandomInt

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

func RandomUInt64() uint64

RandomUInt64 returns a random uint64

func SetVal

func SetVal(key string, val interface{})

SetVal stores key value to viper

func SetupTestLogging

func SetupTestLogging()

SetupTestLogging sets the default log levels for gossip unit tests

func StringsToBytes

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

type Equals

Equals returns whether a and b are the same

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

type Logger

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
}

func GetLogger

func GetLogger(name string, peerID string) Logger

GetLogger returns a logger for given gossip logger name and peerID

type MembershipStore

MembershipStore struct which encapsulates membership message store abstraction

type MembershipStore struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewMembershipStore

func NewMembershipStore() *MembershipStore

NewMembershipStore creates new membership store instance

func (*MembershipStore) MsgByID

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

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

func (*MembershipStore) Put

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

Put associates msg with the given pkiID

func (*MembershipStore) Remove

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

Remove removes a message with a given pkiID

func (*MembershipStore) Size

func (m *MembershipStore) Size() int

Size of the membership store

func (*MembershipStore) ToSlice

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

ToSlice returns a slice backed by the elements of the MembershipStore

type PrivateRWSet

PrivateRWSet contains the bytes of CollectionPvtReadWriteSet

type PrivateRWSet []byte

func (PrivateRWSet) Digest

func (rws PrivateRWSet) Digest() string

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

type PrivateRWSetWithConfig

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

type PrivateRWSetWithConfig struct {
    RWSet            []PrivateRWSet
    CollectionConfig *common.CollectionConfig
}

type PubSub

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.

type PubSub struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewPubSub

func NewPubSub() *PubSub

NewPubSub creates a new PubSub with an empty set of subscriptions

func (*PubSub) Publish

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

Publish publishes an item to all subscribers on the topic

func (*PubSub) Subscribe

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

PvtDataCollections data type to encapsulate collections of private data

type PvtDataCollections []*ledger.TxPvtData

func (*PvtDataCollections) Marshal

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

Marshal encodes private collection into bytes array

func (*PvtDataCollections) Unmarshal

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

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

type Set

Set is a generic and thread-safe set container

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

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) Size

func (s *Set) Size() int

Size returns the size of 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

type Subscription

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

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)
}