protocol

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDifficulty = errorsmod.New(codespace, 1, "difficulty error")
)

Functions

func CountHashDifficultyBits

func CountHashDifficultyBits(bz []byte) (int, error)

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

func MustCountDifficultyBits(bz []byte) int

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.

Jump to

Keyboard shortcuts

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