util

package
v0.0.0-...-e3e94bd Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscoveryLogger = "gossip.discovery"
	ElectionLogger  = "gossip.election"
	CommLogger      = "gossip.comm"
	ConnLogger      = "gossip.comm.conn"
)

Variables

This section is empty.

Functions

func Contains

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

func CreateGRPCLayer

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

func GenerateTLSCertificatesOrPanic

func GenerateTLSCertificatesOrPanic() tls.Certificate

func GetLogger

func GetLogger(model string, endpoint string) *hlogging.HyperchainLogger

func GetRandomIndices

func GetRandomIndices(indiceCount, highestIndex int) []int

GetRandomIndices 将 [0,highestIndex] 区间内的所有数字打乱,然后取前 indiceCount 个数字返回。

func IndexInSlice

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

func RandomIntn

func RandomIntn(n int) int

func RandomUint64

func RandomUint64() uint64

Types

type Equals

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

type MembershipStore

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

MembershipStore 结构体中定义了一个字段:map[string]*protoext.SignedGossipMessage,PKI-ID => *protoext.SignedGossipMessage, 用于存储哪个 peer 节点产生了什么 *protoext.SignedGossipMessage。

func NewMembershipStore

func NewMembershipStore() *MembershipStore

func (*MembershipStore) MsgByID

MsgByID 根据给定的 PKI-ID,返回 MembershipStore 中存储的 *protoext.SignedGossipMessage。

func (*MembershipStore) Put

func (*MembershipStore) Remove

func (ms *MembershipStore) Remove(pkiID common.PKIid)

func (*MembershipStore) Size

func (ms *MembershipStore) Size() int

Size 返回 store 中存储的 PKI-ID 的数量。

func (*MembershipStore) ToSlice

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

type PubSub

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

func NewPubSub

func NewPubSub() *PubSub

func (*PubSub) Publish

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

func (*PubSub) Size

func (ps *PubSub) Size() int

Size 返回所有订阅者的数量。

func (*PubSub) Subscribe

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

type Set

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

func NewSet

func NewSet() *Set

func (*Set) Add

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

func (*Set) Clear

func (s *Set) Clear()

func (*Set) Exists

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

func (*Set) Remove

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

func (*Set) Size

func (s *Set) Size() int

func (*Set) ToArray

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

type Subscription

type Subscription interface {
	Listen() (interface{}, error)
}

Jump to

Keyboard shortcuts

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