util

package
v0.0.0-...-fbe82ab Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

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

用于记录器初始化的记录器名称。

Variables

This section is empty.

Functions

func BytesToStrings

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

func Contains

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

包含返回给定切片a是否包含字符串s

func GetDurationOrDefault

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

GetDurationOrDefault返回配置中的持续时间值(如果存在),否则返回默认值

func GetFloat64OrDefault

func GetFloat64OrDefault(key string, defVal float64) float64

如果存在,则getfloat64ordefault从config返回float64值,否则返回默认值。

func GetIntOrDefault

func GetIntOrDefault(key string, defVal int) int

如果存在,则getIntorDefault返回config中的int值,否则返回默认值

func GetRandomIndices

func GetRandomIndices(indiceCount, highestIndex int) []int

GetRandomIndexs返回一段随机索引 从0到给定的高位

func IndexInSlice

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

indexinslice返回数组中给定对象o的索引

func PrintStackTrace

func PrintStackTrace()

printstacktrace打印到stdout 所有虎尾鹦鹉

func PrivateRWSets

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

privaterwset创建rwset的聚合切片

func RandomInt

func RandomInt(n int) int

RandomNT以int形式返回[0,n]中的非负伪随机整数。 如果n<=0,它会恐慌

func RandomUInt64

func RandomUInt64() uint64

randomunt64返回随机uint64

func SetVal

func SetVal(key string, val interface{})

setval将键值存储到viper

func SetupTestLogging

func SetupTestLogging()

SETUPTESTLOGING设置八卦单元测试的默认日志级别

func StringsToBytes

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

Types

type Equals

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

等于返回A和B是否相同

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返回给定八卦记录器名称和peerID的记录器

type MembershipStore

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

封装的MembershipStore结构 成员身份消息存储抽象

func NewMembershipStore

func NewMembershipStore() *MembershipStore

NewMembershipStore创建新的成员存储实例

func (*MembershipStore) MsgByID

msgbyid返回由特定ID或nil存储的消息 如果找不到这样的身份证

func (*MembershipStore) Put

将关联的MSG与给定的PKIID一起放置

func (*MembershipStore) Remove

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

删除删除具有给定pkiid的邮件

func (*MembershipStore) Size

func (m *MembershipStore) Size() int

会员店规模

func (*MembershipStore) ToSlice

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

ToSlice返回由元素支持的切片 成员关系存储区的

type PrivateRWSet

type PrivateRWSet []byte

privaterwset包含collectionpvtreadwriteset的字节

func (PrivateRWSet) Digest

func (rws PrivateRWSet) Digest() string

Digest返回privaterwset的确定性和无冲突表示

type PrivateRWSetWithConfig

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

privaterwsetwithconfig封装了私有读写集 其中与集合相关的配置信息

type PubSub

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

pubsub定义了一个可以用来: -将项目发布到多个订阅服务器的主题 -订阅主题中的项目 订阅有一个TTL,当它通过时将被清除。

func NewPubSub

func NewPubSub() *PubSub

new pubsub创建一个新的pubsub,其中 订阅集

func (*PubSub) Publish

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

发布将项目发布到主题上的所有订阅服务器

func (*PubSub) Subscribe

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

订阅返回对给定TTL通过时过期的主题的订阅

type PvtDataCollections

type PvtDataCollections []*ledger.TxPvtData

用于封装集合的pvtDataCollections数据类型 私人数据

func (*PvtDataCollections) Marshal

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

封送将私有集合编码为字节数组

func (*PvtDataCollections) Unmarshal

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

解组读取和解组收集私人数据 从给定的字节数组

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

无论给定项是否在集合中,exists返回true

func (*Set) Remove

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

移除从集合中移除给定项

func (*Set) Size

func (s *Set) Size() int

SIZE返回集合的大小

func (*Set) ToArray

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

ToArray返回带有项的切片 在调用该方法时

type Subscription

type Subscription interface {
	//在发布之前侦听块
	//订阅,或者如果
	//订阅的TTL已通过
	Listen() (interface{}, error)
}

订阅定义对主题的订阅 可用于接收发布

Jump to

Keyboard shortcuts

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