common

package
v0.0.0-...-d9e9996 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContractExecutionTimeout common error for contract timeout
	ErrContractExecutionTimeout = errors.New("contract execution timeout")
	// ErrContractConnectionError connect error
	ErrContractConnectionError = errors.New("can't connect contract")
	ErrKVNotFound              = errors.New("Key not found")
)

Functions

func GetBlkHeaderSerializedSize

func GetBlkHeaderSerializedSize(pIntBlk *pb.InternalBlock) (n int64, err error)

GetBlkHeaderSerializedSize get size(in bytes) of a internal block's header info, which will be written to db

func GetFileContent

func GetFileContent(file string) string

GetFileContent read file content and return moved from console/xcmd.go

func GetIntBlkSerializedSize

func GetIntBlkSerializedSize(pIntBlk *pb.InternalBlock) (n int64, err error)

GetIntBlkSerializedSize get size(in bytes) of a internal block after being serialized blockSize = headerSize + sum(txSize)

func GetTxSerializedSize

func GetTxSerializedSize(pTx *pb.Transaction) (n int64, err error)

GetTxSerializedSize get size(in bytes) of a tx after being serialized https://godoc.org/github.com/golang/protobuf/proto#Size

func NormalizedKVError

func NormalizedKVError(err error) error

func UniqSlice

func UniqSlice(slice []string) []string

UniqSlice de-duplication function `

func ValidContractName

func ValidContractName(contractName string) error

ValidContractName check if contract name is ok

Types

type BatchChan

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

BatchChan 将单条的chan包装成batch的chan

func NewBatchChan

func NewBatchChan(window int, waitms int, itemChan chan *pb.Transaction) *BatchChan

NewBatchChan New BatchChan

func (*BatchChan) GetQueue

func (bc *BatchChan) GetQueue() chan []*pb.Transaction

GetQueue 得到当前打包的transaction queue

type LRUCache

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

LRUCache cache struct

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

NewLRUCache New function

func (*LRUCache) Add

func (c *LRUCache) Add(key interface{}, value interface{}) bool

Add add a key-value pair to LRU cache Params:

  • key : cache key
  • value: cache value

Return:

  • evictOrNot: true if eviction occurs, false if not

func (*LRUCache) Del

func (c *LRUCache) Del(key interface{})

Del delete cached value from cache Params:

  • key: cache key

func (*LRUCache) EnlargeCapacity

func (c *LRUCache) EnlargeCapacity(newCapacity int) error

EnlargeCapacity enlarge the capacity of cache

func (*LRUCache) Get

func (c *LRUCache) Get(key interface{}) (interface{}, bool)

Get get cached value from LRU cache Params:

  • key: cache key

Return:

  • value: cache value
  • ok : true if found, false if not

func (*LRUCache) Keys

func (c *LRUCache) Keys() []interface{}

Keys get keys of items in cache

func (*LRUCache) Len

func (c *LRUCache) Len() int

Len get number of items in cache

type Pair

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

Pair <key, value>

type ServerError

type ServerError struct {
	Errno pb.AChainErrorEnum
}

ServerError AmpChain.proto error

func (ServerError) Error

func (err ServerError) Error() string

Error convert to name

Directories

Path Synopsis
Package events is the event center for internal system events.
Package events is the event center for internal system events.

Jump to

Keyboard shortcuts

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