tendermint: github.com/tendermint/tendermint/crypto/multisig/bitarray Index | Files

package bitarray

import "github.com/tendermint/tendermint/crypto/multisig/bitarray"


Package Files


type CompactBitArray Uses

type CompactBitArray struct {
    ExtraBitsStored byte   `json:"extra_bits"` // The number of extra bits in elems.
    Elems           []byte `json:"bits"`

CompactBitArray is an implementation of a space efficient bit array. This is used to ensure that the encoded data takes up a minimal amount of space after amino encoding. This is not thread safe, and is not intended for concurrent usage.

func CompactUnmarshal Uses

func CompactUnmarshal(bz []byte) (*CompactBitArray, error)

CompactUnmarshal is a space efficient decoding for CompactBitArray. It is not amino compatible.

func NewCompactBitArray Uses

func NewCompactBitArray(bits int) *CompactBitArray

NewCompactBitArray returns a new compact bit array. It returns nil if the number of bits is zero.

func (*CompactBitArray) CompactMarshal Uses

func (bA *CompactBitArray) CompactMarshal() []byte

CompactMarshal is a space efficient encoding for CompactBitArray. It is not amino compatible.

func (*CompactBitArray) Copy Uses

func (bA *CompactBitArray) Copy() *CompactBitArray

Copy returns a copy of the provided bit array.

func (*CompactBitArray) GetIndex Uses

func (bA *CompactBitArray) GetIndex(i int) bool

GetIndex returns the bit at index i within the bit array. The behavior is undefined if i >= bA.Size()

func (*CompactBitArray) MarshalJSON Uses

func (bA *CompactBitArray) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface by marshaling bit array using a custom format: a string of '-' or 'x' where 'x' denotes the 1 bit.

func (*CompactBitArray) NumTrueBitsBefore Uses

func (bA *CompactBitArray) NumTrueBitsBefore(index int) int

NumTrueBitsBefore returns the number of bits set to true before the given index. e.g. if bA = _XX__XX, NumOfTrueBitsBefore(4) = 2, since there are two bits set to true before index 4.

func (*CompactBitArray) SetIndex Uses

func (bA *CompactBitArray) SetIndex(i int, v bool) bool

SetIndex sets the bit at index i within the bit array. The behavior is undefined if i >= bA.Size()

func (*CompactBitArray) Size Uses

func (bA *CompactBitArray) Size() int

Size returns the number of bits in the bitarray

func (*CompactBitArray) String Uses

func (bA *CompactBitArray) String() string

String returns a string representation of CompactBitArray: BA{<bit-string>}, where <bit-string> is a sequence of 'x' (1) and '_' (0). The <bit-string> includes spaces and newlines to help people. For a simple sequence of 'x' and '_' characters with no spaces or newlines, see the MarshalJSON() method. Example: "BA{_x_}" or "nil-BitArray" for nil.

func (*CompactBitArray) StringIndented Uses

func (bA *CompactBitArray) StringIndented(indent string) string

StringIndented returns the same thing as String(), but applies the indent at every 10th bit, and twice at every 50th bit.

func (*CompactBitArray) UnmarshalJSON Uses

func (bA *CompactBitArray) UnmarshalJSON(bz []byte) error

UnmarshalJSON implements json.Unmarshaler interface by unmarshaling a custom JSON description.

Package bitarray imports 6 packages (graph) and is imported by 3 packages. Updated 2019-12-20. Refresh now. Tools for package owners.