MCPcopy Create free account
hub / github.com/tendermint/tendermint / Bytes

Method Bytes

libs/bits/bit_array.go:343–355  ·  view source on GitHub ↗

Bytes returns the byte representation of the bits within the bitarray.

()

Source from the content-addressed store, hash-verified

341
342// Bytes returns the byte representation of the bits within the bitarray.
343func (bA *BitArray) Bytes() []byte {
344 bA.mtx.Lock()
345 defer bA.mtx.Unlock()
346
347 numBytes := (bA.Bits + 7) / 8
348 bytes := make([]byte, numBytes)
349 for i := 0; i < len(bA.Elems); i++ {
350 elemBytes := [8]byte{}
351 binary.LittleEndian.PutUint64(elemBytes[:], bA.Elems[i])
352 copy(bytes[i*8:], elemBytes[:])
353 }
354 return bytes
355}
356
357// Update sets the bA's bits to be that of the other bit array.
358// The copying begins from the begin of both bit arrays.

Callers 1

TestBytesFunction · 0.95

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1

TestBytesFunction · 0.76