Documentation ¶
Index ¶
- Variables
- func CountHashDifficultyBits(bz []byte) (int, error)
- func GetEarliestCreateClaimHeight(ctx context.Context, createClaimWindowStartBlock client.Block) int64
- func GetEarliestSubmitProofHeight(ctx context.Context, submitProofWindowStartBlock client.Block) int64
- func MustCountDifficultyBits(bz []byte) int
Constants ¶
This section is empty.
Variables ¶
var (
ErrDifficulty = errorsmod.New(codespace, 1, "difficulty error")
)
Functions ¶
func CountHashDifficultyBits ¶
CountHashDifficultyBits returns the number of leading zero bits in the given byte slice. It returns an error if the byte slice is all zero bits.
TODO_IMPROVE(@h5law): Remove the forloop logic and replace with a simplified single method that accounts for the fact that block hashes/paths are always 32 bytes. We use Sha256 (32 bytes) and CosmosSDK defaults to 32 byte block hashes so specifying makes sense here.
func CountHashDifficultyBits(bz [32]byte) int { return bits.LeadingZeros64(binary.LittleEndian.Uint64(bz)) }
The above would mean we can replace MustCountDifficultyBits entirely.
func GetEarliestCreateClaimHeight ¶
func GetEarliestCreateClaimHeight(ctx context.Context, createClaimWindowStartBlock client.Block) int64
GetEarliestCreateClaimHeight returns the earliest block height at which a claim for a session with the given createClaimWindowStartHeight can be created.
TODO_TEST(@bryanchriswhite): Add test coverage and more logs
func GetEarliestSubmitProofHeight ¶
func GetEarliestSubmitProofHeight(ctx context.Context, submitProofWindowStartBlock client.Block) int64
GetEarliestSubmitProofHeight returns the earliest block height at which a proof for a session with the given submitProofWindowStartHeight can be submitted.
TODO_TEST(@bryanchriswhite): Add test coverage and more logs
func MustCountDifficultyBits ¶
MustCountDifficultyBits returns the number of leading zero bits in the given byte slice. It panics if an error is encountered.
Types ¶
This section is empty.