Documentation ¶
Index ¶
- func AddLogFile(filepath string, maxSize int)
- func AddLogHandler(handler log.Handler)
- func AnalysisEnd(name string, more ...interface{})
- func AnalysisStart(name string, more ...interface{})
- func AppendIfMissing(slice []common.Address, addr common.Address) ([]common.Address, bool)
- func AskForPassphrase(prompt string) string
- func CountOneBits(arr []byte) int64
- func FatalErrMsg(err error, format string, args ...interface{})
- func FatalError(err error)
- func FromHex(s string) []byte
- func GenKeyP2P(ip, port string) (p2p_crypto.PrivKey, p2p_crypto.PubKey, error)
- func GenKeyP2PRand() (p2p_crypto.PrivKey, p2p_crypto.PubKey, error)
- func GetAddressFromBLSPubKey(pubKey *bls.PublicKey) common.Address
- func GetAddressFromBLSPubKeyBytes(pubKeyBytes []byte) common.Address
- func GetLogInstance() log.Logger
- func GetLogger() log.Logger
- func GetPassphraseFromSource(src string) (pass string, err error)
- func GetPendingCXKey(shardID uint32, blockNum uint64) string
- func GetUniqueIDFromIPPort(ip, port string) uint32
- func Hex2Bytes(str string) []byte
- func IsPrivateIP(ip net.IP) bool
- func Load(path string, v interface{}) error
- func LoadKeyFromFile(keyfile string) (key p2p_crypto.PrivKey, pk p2p_crypto.PubKey, err error)
- func LoadPrivateKey(key string) (p2p_crypto.PrivKey, p2p_crypto.PubKey, error)
- func Logger() *zerolog.Logger
- func Marshal(v interface{}) (io.Reader, error)
- func PrintError(err error)
- func Save(path string, v interface{}) error
- func SaveKeyToFile(keyfile string, key p2p_crypto.PrivKey) (err error)
- func SavePrivateKey(key p2p_crypto.PrivKey) (string, error)
- func SetLogContext(_port, _ip string)
- func SetLogVerbosity(verbosity log.Lvl)
- func Unmarshal(r io.Reader, v interface{}) error
- func WithCaller(logger log.Logger) log.Logger
- func WithCallerSkip(logger log.Logger, skip int) log.Logger
- type PrivKeyStore
- type Timeout
- type TimeoutState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLogFile ¶
AddLogFile creates a StreamHandler that outputs JSON logs into rotating files with specified max file size
func AnalysisEnd ¶ added in v1.3.6
func AnalysisEnd(name string, more ...interface{})
AnalysisEnd ..
func AnalysisStart ¶ added in v1.3.6
func AnalysisStart(name string, more ...interface{})
AnalysisStart ..
func AppendIfMissing ¶ added in v1.3.0
AppendIfMissing appends an item if it's missing in the slice, returns appended slice and true Otherwise, return the original slice and false
func AskForPassphrase ¶
AskForPassphrase return passphrase using password input
func CountOneBits ¶
CountOneBits counts the number of 1 bit in byte array
func FatalErrMsg ¶ added in v1.3.0
FatalErrMsg prints the given error wrapped with the given message in the extended format (%+v) onto stderr, then exits with status 1.
func FatalError ¶ added in v1.3.0
func FatalError(err error)
FatalError prints the given error in the extended format (%+v) onto stderr, then exits with status 1.
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GenKeyP2P ¶
func GenKeyP2P(ip, port string) (p2p_crypto.PrivKey, p2p_crypto.PubKey, error)
GenKeyP2P generates a pair of RSA keys used in libp2p host
func GenKeyP2PRand ¶
func GenKeyP2PRand() (p2p_crypto.PrivKey, p2p_crypto.PubKey, error)
GenKeyP2PRand generates a pair of RSA keys used in libp2p host, using random seed
func GetAddressFromBLSPubKey ¶ added in v1.3.7
GetAddressFromBLSPubKey return the address object from bls pub key.
func GetAddressFromBLSPubKeyBytes ¶ added in v1.3.7
GetAddressFromBLSPubKeyBytes return the address object from bls pub key.
func GetPassphraseFromSource ¶
GetPassphraseFromSource reads a passphrase such as a key-encrypting one non-interactively from the given source.
The source can be "pass:password", "env:var", "file:pathname", "fd:number", or "stdin". See “PASS PHRASE ARGUMENTS” section of openssl(1) for details.
When "stdin" or "fd:" is used, the standard input or the given file descriptor is exhausted. Therefore, this function should be called at most once per program invocation; the second call, if any, may return an empty string if "stdin" or "fd" is used.
func GetPendingCXKey ¶
GetPendingCXKey creates pending CXReceiptsProof key given shardID and blockNum it is to avoid adding duplicated CXReceiptsProof from the same source shard
func GetUniqueIDFromIPPort ¶
GetUniqueIDFromIPPort --
func IsPrivateIP ¶
IsPrivateIP checks if an IP address is private or not
func LoadKeyFromFile ¶
func LoadKeyFromFile(keyfile string) (key p2p_crypto.PrivKey, pk p2p_crypto.PubKey, err error)
LoadKeyFromFile load private key from keyfile If the private key is not loadable or no file, it will generate a new random private key
func LoadPrivateKey ¶
func LoadPrivateKey(key string) (p2p_crypto.PrivKey, p2p_crypto.PubKey, error)
LoadPrivateKey parses the key string in base64 format and return PrivKey
func PrintError ¶ added in v1.3.0
func PrintError(err error)
PrintError prints the given error in the extended format (%+v) onto stderr.
func SaveKeyToFile ¶
func SaveKeyToFile(keyfile string, key p2p_crypto.PrivKey) (err error)
SaveKeyToFile save private key to keyfile
func SavePrivateKey ¶
func SavePrivateKey(key p2p_crypto.PrivKey) (string, error)
SavePrivateKey convert the PrivKey to base64 format and return string
func SetLogContext ¶
func SetLogContext(_port, _ip string)
SetLogContext used to print out loggings of node with port and ip. Every instance (node, etc..) needs to set this for logging.
func SetLogVerbosity ¶
SetLogVerbosity specifies the verbosity of global logger
func Unmarshal ¶
Unmarshal is a function that unmarshals the data from the reader into the specified value.
func WithCaller ¶
WithCaller logs the caller info in three context items "funcFile", "funcLine", and "funcName".
Types ¶
type PrivKeyStore ¶
type PrivKeyStore struct {
Key string `json:"key"`
}
PrivKeyStore is used to persist private key to/from file
type Timeout ¶
type Timeout struct {
// contains filtered or unexported fields
}
Timeout is the implementation of timeout
func (*Timeout) CheckExpire ¶
CheckExpire checks whether the timeout is reached/expired
func (*Timeout) IsActive ¶
IsActive checks whether timeout clock is active; A timeout is active means it's not stopped caused by stop and also not expired with time elapses longer than duration from start
func (*Timeout) SetDuration ¶
SetDuration set new duration for the timer
type TimeoutState ¶
type TimeoutState int
TimeoutState indicates the state of Timeout class
const ( Active TimeoutState = iota Inactive Expired )
Enum for different TimeoutState