utils

package
Version: v1.65.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

Package utils p2p utils

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcChannelVersion

func CalcChannelVersion(channel, version int32) int32

CalcChannelVersion calc channel version

func DecodeChannelVersion

func DecodeChannelVersion(channelVersion int32) (channel int32, version int32)

DecodeChannelVersion decode channel version

Types

type Filterdata

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

Filterdata filter data attribute

func NewFilter

func NewFilter(num int) *Filterdata

NewFilter produce a filter object

func (*Filterdata) Add

func (f *Filterdata) Add(key string, val interface{}) bool

Add add val

func (*Filterdata) AddWithCheckAtomic

func (f *Filterdata) AddWithCheckAtomic(key string, val interface{}) (exist bool)

AddWithCheckAtomic add key if key not exist with atomic lock, return true if exist

func (*Filterdata) Close

func (f *Filterdata) Close()

Close the filter object

func (*Filterdata) Contains

func (f *Filterdata) Contains(key string) bool

Contains query receive data by key

func (*Filterdata) Get

func (f *Filterdata) Get(key string) (interface{}, bool)

Get get val

func (*Filterdata) GetAtomicLock

func (f *Filterdata) GetAtomicLock()

GetAtomicLock get lock

func (*Filterdata) ManageRecvFilter

func (f *Filterdata) ManageRecvFilter(tickTime time.Duration)

ManageRecvFilter manager receive filter

func (*Filterdata) ReleaseAtomicLock

func (f *Filterdata) ReleaseAtomicLock()

ReleaseAtomicLock release lock

func (*Filterdata) Remove

func (f *Filterdata) Remove(key string)

Remove remove receive data by key

type SpaceLimitCache

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

SpaceLimitCache lru缓存封装, 控制占用空间大小

func NewSpaceLimitCache

func NewSpaceLimitCache(num, maxByteSize int) *SpaceLimitCache

NewSpaceLimitCache new space limit cache

func (*SpaceLimitCache) Add

func (c *SpaceLimitCache) Add(key interface{}, val interface{}, size int) bool

Add add key val

func (*SpaceLimitCache) Contains

func (c *SpaceLimitCache) Contains(key interface{}) bool

Contains check if exist

func (*SpaceLimitCache) Get

func (c *SpaceLimitCache) Get(key interface{}) interface{}

Get get key

func (*SpaceLimitCache) Remove

func (c *SpaceLimitCache) Remove(key interface{}) (interface{}, bool)

Remove remove key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL