MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / BitArray

Method BitArray

types/block.go:841–851  ·  view source on GitHub ↗

BitArray returns a BitArray of which validators voted for BlockID or nil in this commit. Implements VoteSetReader.

()

Source from the content-addressed store, hash-verified

839// BitArray returns a BitArray of which validators voted for BlockID or nil in this commit.
840// Implements VoteSetReader.
841func (commit *Commit) BitArray() *bits.BitArray {
842 if commit.bitArray == nil {
843 commit.bitArray = bits.NewBitArray(len(commit.Signatures))
844 for i, commitSig := range commit.Signatures {
845 // TODO: need to check the BlockID otherwise we could be counting conflicts,
846 // not just the one with +2/3 !
847 commit.bitArray.SetIndex(i, !commitSig.Absent())
848 }
849 }
850 return commit.bitArray
851}
852
853// GetByIndex returns the vote corresponding to a given validator index.
854// Panics if `index >= commit.Size()`.

Callers

nothing calls this directly

Calls 3

NewBitArrayFunction · 0.92
AbsentMethod · 0.80
SetIndexMethod · 0.45

Tested by

no test coverage detected