Documentation ¶
Index ¶
- Constants
- func CalcPastMedianTime(timestamps []int) (time.Time, error)
- func DecodeAndReverseHashString(hexStr string) ([32]byte, error)
- func DecodeAndReverseHexString(hexStr string) ([]byte, error)
- func DisableCanonicalMode(optionalLogger ...Logger) *ttyState
- func GetBitcoinHash(b []byte) []byte
- func GetGRPCClient(ctx context.Context, address string, connectionOptions *ConnectionOptions) (*grpc.ClientConn, error)
- func GetGRPCServer(connectionOptions *ConnectionOptions) (*grpc.Server, error)
- func GetIPAddressesWithHint(hintRegex string) ([]string, error)
- func GetPublicIPAddress() (string, error)
- func ISOFormat(timestamp time.Time) string
- func InitGlobalTracer(serviceName string) (opentracing.Tracer, io.Closer, error)
- func RestoreTTY(state *ttyState)
- func ReverseAndHexEncodeHash(b32 [32]byte) string
- func ReverseAndHexEncodeSlice(b []byte) string
- func ReverseHash(a [32]byte) [32]byte
- func ReverseHashInPlace(a *[32]byte)
- 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
- func UTXOHash(previousTxid *chainhash.Hash, index uint32, lockingScript []byte, ...) (*chainhash.Hash, error)
- type ConnectionOptions
- type Logger
- type Pair
- type PasswordCredentials
Constants ¶
const ONE_GIGABYTE = 1024 * 1024 * 1024
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 DecodeAndReverseHashString ¶ added in v1.0.32
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 GetGRPCClient ¶ added in v1.0.35
func GetGRPCClient(ctx context.Context, address string, connectionOptions *ConnectionOptions) (*grpc.ClientConn, error)
func GetGRPCServer ¶ added in v1.0.35
func GetGRPCServer(connectionOptions *ConnectionOptions) (*grpc.Server, error)
func GetIPAddressesWithHint ¶ added in v1.0.24
func GetPublicIPAddress ¶ added in v1.0.46
func InitGlobalTracer ¶ added in v1.0.40
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 ReverseAndHexEncodeHash ¶ added in v1.0.33
func ReverseAndHexEncodeSlice ¶ added in v1.0.33
ReverseAndHexEncodeSlice encodes the given byte slice to a hex string and then reverses the bytes.
func ReverseHash ¶ added in v1.0.32
func ReverseHashInPlace ¶ added in v1.0.32
func ReverseHashInPlace(a *[32]byte)
Reverse the elements of a 32 byte hash in place
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.
func SafeSend ¶
SafeSend is a helper function that sends a value on a channel and returns. It is safe to use with closed channels. It uses go generics to allow for any type of channel.
Types ¶
type ConnectionOptions ¶ added in v1.0.35
type ConnectionOptions struct { MaxMessageSize int // Max message size in bytes SecurityLevel int // 0 = insecure, 1 = secure, 2 = secure with client cert OpenTelemetry bool // Enable OpenTelemetry tracing OpenTracing bool // Enable OpenTelemetry tracing Prometheus bool // Enable Prometheus metrics CertFile string // CA cert file if SecurityLevel > 0 CaCertFile string // CA cert file if SecurityLevel > 0 KeyFile string // Client key file if SecurityLevel > 1 MaxRetries int // Max number of retries for transient errors RetryBackoff time.Duration // Backoff between retries Credentials PasswordCredentials // Credentials to pass to downstream middleware (optional) }
type Pair ¶ added in v1.0.11
type Pair[F, S any] struct { First F Second S }
Pair is a simple struct that holds two values.
type PasswordCredentials ¶ added in v1.0.35
--------------------------------------------------------------------- The PasswordCredentials type and the receivers it implements, allow us to use the grpc.WithPerRPCCredentials() dial option to pass credentials to downstream middleware
func NewPassCredentials ¶ added in v1.0.35
func NewPassCredentials(m map[string]string) PasswordCredentials
func (PasswordCredentials) GetRequestMetadata ¶ added in v1.0.35
func (PasswordCredentials) RequireTransportSecurity ¶ added in v1.0.35
func (PasswordCredentials) RequireTransportSecurity() bool