Documentation ¶
Index ¶
- func CalcPastMedianTime(timestamps []int) (time.Time, error)
- func DecodeAndReverseHexString(hexStr string) ([]byte, error)
- func DisableCanonicalMode(optionalLogger ...Logger) *ttyState
- func GetBitcoinHash(b []byte) []byte
- func GetIPAddressesWithHint(hintRegex string) ([]string, error)
- func HexEncodeAndReverseBytes(b []byte) string
- func RestoreTTY(state *ttyState)
- func ReverseSlice[T any](a []T) []T
- func ReverseSliceInPlace[T any](a []T)
- func SafeSend[T any](ch chan T, t T, timeoutOption ...time.Duration) bool
- func Sha256d(b []byte) []byte
- type Logger
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcPastMedianTime ¶ added in v1.0.25
CalcPastMedianTime calculates the median time of the previous few blocks prior to, and including, the block node.
This function is safe for concurrent access.
func DecodeAndReverseHexString ¶ added in v1.0.8
DecodeAndReverseHexString decodes the given hex string and then reverses the bytes. This is useful for converting Bitcoin hex strings to byte slices in little endian format.
func DisableCanonicalMode ¶ added in v1.0.5
func DisableCanonicalMode(optionalLogger ...Logger) *ttyState
DisableCanonicalMode disables canonical mode on the terminal. This allows for reading single characters without pressing enter. The previous state is returned and can be used to restore the previous state. The optionalLogger can be used a preferred logger. If no optionalLogger is provided, a default logger is used.
Usage in main.go: defer utils.RestoreTTY(utils.DisableCanonicalMode())
func GetBitcoinHash ¶ added in v1.0.7
GetBitcoinHash calculates the Bitcoin hash of the given bytes. The Bitcoin hash is the double SHA-256 hash of the given bytes which is then reversed. For transactions the entire transaction bytes are hashed; for blocks only the header (80 bytes) is hashed.
func GetIPAddressesWithHint ¶ added in v1.0.24
func HexEncodeAndReverseBytes ¶ added in v1.0.14
HexEncodeAndReverseBytes encodes the given byte slice to a hex string and then reverses the bytes.
func RestoreTTY ¶ added in v1.0.5
func RestoreTTY(state *ttyState)
RestoreTTY restores the previous state of the terminal. The previous state is returned by DisableCanonicalMode. If the ttyState is nil, nothing is done.
func ReverseSlice ¶ added in v1.0.6
func ReverseSlice[T any](a []T) []T
ReverseSlice reverses the order of the items in the slice. A copy of the slice is returned.
func ReverseSliceInPlace ¶ added in v1.0.14
func ReverseSliceInPlace[T any](a []T)
ReverseSliceInPlace reverses the given slice in place.