util

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2018 License: Apache-2.0 Imports: 35 Imported by: 16

Documentation

Index

Constants

View Source
const (
	FormattedBigIntLength = 80
	HomeConfigDir         = ".sonm"
	DefaultKeystorePath   = "keystore"
)
View Source
const (
	WorkerAddressHeader = "x-worker-eth-addr"
)

Variables

This section is empty.

Functions

func BigIntToPaddedString added in v0.4.1

func BigIntToPaddedString(x *big.Int) string

func DirectoryExists added in v0.3.0

func DirectoryExists(p string) error

DirectoryExists returns true if the given directory exists

func ExtractMethod added in v0.3.0

func ExtractMethod(fullMethod string) string

func FileExists added in v0.4.1

func FileExists(p string) error

func ForwardMetadata added in v0.3.0

func ForwardMetadata(ctx context.Context) context.Context

ForwardMetadata is a helper function for gRPC proxy that chains incoming request with some outgoing request. It simply forwards incoming context metadata without changes by toggling internal outgoing key.

func GenerateCert added in v0.3.0

func GenerateCert(ethpriv *ecdsa.PrivateKey, validPeriod time.Duration) (cert []byte, key []byte, err error)

GenerateCert generates new PEM encoded x509cert and privatekey key. Generated certificate contains signature of a publick key by eth key

func GetDefaultConfigDir added in v0.4.1

func GetDefaultConfigDir() (string, error)

GetDefaultConfigDir returns default user's config dir. e.g: /home/user/.sonm

func GetDefaultKeyStoreDir added in v0.4.1

func GetDefaultKeyStoreDir() (string, error)

GetDefaultKeyStoreDir returns default keystore dir for current user. e.g: /home/user/.sonm/keystore

func GetPlatformName added in v0.3.0

func GetPlatformName() string

func GetUserHomeDir added in v0.3.0

func GetUserHomeDir() (homeDir string, err error)

GetUserHomeDir returns home for current user. e.g: /home/user

func HexToAddress added in v0.4.1

func HexToAddress(hex string) (common.Address, error)

func NewTLS added in v0.3.0

NewTLS wraps TLS TransportCredentials from grpc to add custom logic

func ParseBigInt added in v0.3.0

func ParseBigInt(s string) (*big.Int, error)

ParseBigInt parses the given string and converts it to *big.Int

func StartPrometheus added in v0.3.2

func StartPrometheus(ctx context.Context, listenAddr string)

func StringToEtherPrice added in v0.3.2

func StringToEtherPrice(s string) (*big.Int, error)

StringToEtherPrice converts input string s to Ethereum's price present as big.Int This function expects to receive trimmed input.

Types

type HitlessCertRotator added in v0.3.0

type HitlessCertRotator interface {
	GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)
	GetClientCertificate(*tls.CertificateRequestInfo) (*tls.Certificate, error)
	Close()
}

HitlessCertRotator renews TLS cert periodically

func NewHitlessCertRotator added in v0.3.0

func NewHitlessCertRotator(ctx context.Context, ethPriv *ecdsa.PrivateKey) (HitlessCertRotator, *tls.Config, error)

type ImmediateTicker added in v0.3.0

type ImmediateTicker struct {
	C <-chan time.Time // The channel on which the ticks are delivered.
	// contains filtered or unexported fields
}

func NewImmediateTicker added in v0.3.0

func NewImmediateTicker(d time.Duration) *ImmediateTicker

func (*ImmediateTicker) Stop added in v0.3.0

func (t *ImmediateTicker) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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