util

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSortedKeys

func GetSortedKeys(m interface{}) []string

GetSortedKeys returns the keys of the map in a sorted order. This function assumes that the keys are string

Types

type FilterBitArray

type FilterBitArray []byte

FilterBitArray is an array of bits based on byte unit, so 8 bits at each index. The array automatically increases if the set index is larger than the current capacity. The bit index starts at 0.

func NewFilterBitArray

func NewFilterBitArray(size uint) FilterBitArray

NewFilterBitArray creates an array with the specified bit-size. This is an optimization to make array once for the expected capacity rather than using Set function to auto-increase the array.

func NewFilterBitArrayFromBytes

func NewFilterBitArrayFromBytes(bytes []byte) FilterBitArray

NewFilterBitArrayFromBytes reconstructs an array from given byte array.

func (*FilterBitArray) Capacity

func (ba *FilterBitArray) Capacity() uint

Capacity returns the number of bits in the FilterBitArray.

func (*FilterBitArray) FromBytes

func (ba *FilterBitArray) FromBytes(bytes []byte)

FromBytes accepts a byte array.

func (*FilterBitArray) IsSet

func (ba *FilterBitArray) IsSet(i uint) bool

IsSet returns true if the specified bit-index is 1; false otherwise.

func (*FilterBitArray) Set

func (ba *FilterBitArray) Set(i uint)

Set assigns 1 to the specified bit-index, which is starting from 0. Set automatically increases the array to accommodate the bit-index.

func (*FilterBitArray) SetRange

func (ba *FilterBitArray) SetRange(begin uint, end uint)

SetRange assigns 1 to the bit-indexes specified by range [begin, end] Set automatically increases the array to accommodate the bit-index.

func (*FilterBitArray) ToBytes

func (ba *FilterBitArray) ToBytes() []byte

ToBytes returns the byte array for storage.

func (*FilterBitArray) Unset

func (ba *FilterBitArray) Unset(i uint)

Unset assigns 0 the specified bit-index. If bit-index is larger than capacity, do nothing.

func (*FilterBitArray) UnsetRange

func (ba *FilterBitArray) UnsetRange(begin uint, end uint)

UnsetRange assigns 0 to all bits in range [begin, end]. If bit-index is larger than capacity, do nothing.

func (*FilterBitArray) ValueAt

func (ba *FilterBitArray) ValueAt(i uint) byte

ValueAt returns the value at the specified bit-index. If bit-index is out of range, return 0. Note that the returned value is in byte, so it may be a power of 2 if not 0.

type TxValidationFlags

type TxValidationFlags []uint8

TxValidationFlags is array of transaction validation codes. It is used when commiter validates block.

func NewTxValidationFlags

func NewTxValidationFlags(size int) TxValidationFlags

NewTxValidationFlags Create new object-array of validation codes with target size. Default values: valid.

func (TxValidationFlags) Flag

func (obj TxValidationFlags) Flag(txIndex int) peer.TxValidationCode

Flag returns validation code at specified transaction

func (TxValidationFlags) IsInvalid

func (obj TxValidationFlags) IsInvalid(txIndex int) bool

IsInvalid checks if specified transaction is invalid

func (TxValidationFlags) IsSetTo

func (obj TxValidationFlags) IsSetTo(txIndex int, flag peer.TxValidationCode) bool

IsSetTo returns true if the specified transaction equals flag; false otherwise.

func (TxValidationFlags) IsValid

func (obj TxValidationFlags) IsValid(txIndex int) bool

IsValid checks if specified transaction is valid

func (TxValidationFlags) SetFlag

func (obj TxValidationFlags) SetFlag(txIndex int, flag peer.TxValidationCode)

SetFlag assigns validation code to specified transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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