Documentation ¶
Index ¶
- Variables
- func AmILeading(client layer1.Client, ctx context.Context, logger *logrus.Entry, start int, ...) (bool, error)
- func CloneBigInt(original *big.Int) *big.Int
- func CloneBigInt2(original [2]*big.Int) [2]*big.Int
- func CloneBigInt4(original [4]*big.Int) [4]*big.Int
- func CloneBigIntSlice(original []*big.Int) []*big.Int
- func CloneSliceBigInt2(original [][2]*big.Int) [][2]*big.Int
- func CompareCanonicalVersion(newVersion bindings.CanonicalVersion) (bool, bool, bool, bindings.CanonicalVersion, error)
- func CopySlice(v []byte) []byte
- func DebugTrace(logger *logrus.Logger, err error, s ...string)
- func DecodeHexString(h string) ([]byte, error)
- func DeleteValue(txn *badger.Txn, key []byte) error
- func EncodeHexString(h []byte) string
- func Epoch(height uint32) uint32
- func ForceSliceToLength(inSlice []byte, length int) []byte
- func GetBlocksSinceDesperation(currentHeight, start, desperationDelay int) int
- func GetInt64(txn *badger.Txn, key []byte) (int64, error)
- func GetLocalVersion() (bindings.CanonicalVersion, error)
- func GetObjSize(obj encoding.BinaryMarshaler) (int, error)
- func GetValue(txn *badger.Txn, key []byte) ([]byte, error)
- func HandleBadgerErrors(err error) error
- func LeaderElection(numValidators, myIdx, blocksSinceDesperation, desperationFactor int, ...) bool
- func MarshalInt64(v int64) []byte
- func MarshalUint16(v uint16) []byte
- func MarshalUint32(v uint32) []byte
- func MarshalUint64(v uint64) []byte
- func Max(a, b uint64) uint64
- func Min(a, b uint64) uint64
- func OpenBadger(closeChan <-chan struct{}, directoryName string, inMemory bool) (*badger.DB, error)
- func RandomBytes(num int) ([]byte, error)
- func SetInt64(txn *badger.Txn, key []byte, v int64) error
- func SetValue(txn *badger.Txn, key, value []byte) error
- func SortKVs(keys, values [][]byte) ([][]byte, [][]byte, error)
- func StringToBytes32(str string) (b [32]byte)
- func UnmarshalInt64(v []byte) (int64, error)
- func UnmarshalUint16(v []byte) (uint16, error)
- func UnmarshalUint32(v []byte) (uint32, error)
- func UnmarshalUint64(v []byte) (uint64, error)
- func ValidateHash(hsh []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrDevelopmentVersion = errors.New("not tagged build, running in developer mode") ErrUnexpectedTagFormat = errors.New("unexpected version format. expected vX.Y.Z[-optional]") )
Functions ¶
func AmILeading ¶
func AmILeading(client layer1.Client, ctx context.Context, logger *logrus.Entry, start int, randHash []byte, numOfValidators, validatorIndex, desperationFactor, desperationDelay int) (bool, error)
AmILeading checks if the current node is a leader for an action.
func CloneBigInt ¶
CloneBigInt makes a deep copy of a big.Int.
func CloneBigInt2 ¶
CloneBigInt2 makes a deep copy of an array [2] of big.Int's.
func CloneBigInt4 ¶
CloneBigInt4 makes a deep copy of a array [4] of big.Int's.
func CloneBigIntSlice ¶
CloneBigIntSlice makes a deep copy of a slice of big.Int's.
func CloneSliceBigInt2 ¶
CloneSliceBigInt2 makes a deep copy of a slice of array [2] of big.Int's.
func CompareCanonicalVersion ¶ added in v0.0.5
func CompareCanonicalVersion(newVersion bindings.CanonicalVersion) (bool, bool, bool, bindings.CanonicalVersion, error)
func DebugTrace ¶
DebugTrace allows a traceback to be generated that includes a file name, a line number, the error message, and an optional string. Calling this function using a logger that is set to anthything other than trace or debug level is a no-op. This filtering helps to minimize overhead during normal use but still allows error tracebacks to be created easily. The returned file and line number will point to where this function was called. Although more than one string may be passed, only the first string will be displayed. The varadic property was only used to shorten calling syntax.
func DecodeHexString ¶
func DeleteValue ¶
DeleteValue removes the value for key in the database that is safe for use.
func EncodeHexString ¶
func ForceSliceToLength ¶
ForceSliceToLength will return a byte slice of size length. It will left pad a byte slice to the specified number of zeros if the slice is not long enough. If the slice is too long, it will return the right-most bytes of the slice.
func GetBlocksSinceDesperation ¶ added in v0.0.7
GetBlocksSinceDesperation calculation
func GetLocalVersion ¶ added in v0.0.5
func GetLocalVersion() (bindings.CanonicalVersion, error)
func GetObjSize ¶
func GetObjSize(obj encoding.BinaryMarshaler) (int, error)
GetObjSize returns the size of a marshalled capnproto object.
func HandleBadgerErrors ¶ added in v0.0.2
HandleBadgerErrors handles the badger errors. This function will suppress the errors that we expect to happens and are not harmful to the system.
func LeaderElection ¶ added in v0.0.2
func LeaderElection(numValidators, myIdx, blocksSinceDesperation, desperationFactor int, seedHash []byte, logger *logrus.Entry) bool
LeaderElection runs the leader election algorithm to check if an index is a leader or not.
func MarshalUint16 ¶
MarshalUint16 will marshal an uint16 object.
func MarshalUint32 ¶
MarshalUint32 will marshal an uint32 object.
func MarshalUint64 ¶
MarshalUint64 will marshal a uint64 object.
func OpenBadger ¶
OpenBadger opens a badgerdb database and closes the db when closeChan returns a struct{}{}.
func RandomBytes ¶
RandomBytes will return a byte slice of num random bytes using crypto rand.
func SortKVs ¶
SortKVs allows a pair of slices, one containing keys and one containing values to be sorted by treating each key as a big.Int and preserving the relationship between keys and values during the sort. SortKVs is a copy before sort algorithm. The original slices will remain unsorted.
func StringToBytes32 ¶
StringToBytes32 is useful for convert a Go string into a bytes32 useful calling Solidity.
func UnmarshalInt64 ¶
UnmarshalInt64 will unmarshal an int64 object.
func UnmarshalUint16 ¶
UnmarshalUint16 will unmarshal an uint16 object.
func UnmarshalUint32 ¶
UnmarshalUint32 will unmarshal an uint32 object.
func UnmarshalUint64 ¶
UnmarshalUint64 will unmarshal a uint64 object.
func ValidateHash ¶
ValidateHash checks whether or not hsh has the correct length.
Types ¶
This section is empty.