Documentation ¶
Index ¶
- Constants
- Variables
- func Absolute(path string) (string, error)
- func AddRpcLogger(w io.Writer, id string)
- func ByteToString(p []byte) string
- func BytesToInt16(b []byte) int16
- func BytesToInt64(b []byte) int64
- func BytesToUInt32(b []byte) uint32
- func BytesToUInt64(b []byte) uint64
- func BytesToUint16(b []byte) uint16
- func CalcCRC32(data []byte) uint32
- func CalcCRC32OfSlices(data [][]byte) uint32
- func CalcFileCRC32(filePath string) uint32
- func CalcFileHash(filePath, encryptionTag string, codec byte) string
- func CalcFileHashFromSlices(files []string, encryptionTag string) string
- func CalcFileKeccak(filePath string) mh.Multihash
- func CalcFileMD5(filePath string) []byte
- func CalcHash(data []byte) string
- func CalcHashBytes(data []byte) []byte
- func CalcKeccakOfSplitFiles(files []string) []byte
- func CalcMD5OfSplitFiles(filePath []string) []byte
- func CalcSliceHash(data []byte, fileHash string, sliceNumber uint64) string
- func ChangePassword(walletAddress, dir, auth string, key *AccountKey) error
- func CheckError(err error) bool
- func Crc32IEEE(data []byte) uint32
- func CreateP2PKey(dir, nickname, password, hrp string) (types.Address, error)
- func DebugLog(v ...interface{})
- func DebugLogf(template string, v ...interface{})
- func DebugLogfWithCalldepth(calldepth int, template string, v ...interface{})
- func DetailLog(v ...interface{})
- func DetailLogf(template string, v ...interface{})
- func DisableRpcLogger(id string)
- func DumpTraffic(v ...interface{})
- func ECCSign(text []byte, prk *ecdsa.PrivateKey) ([]byte, error)
- func ECCSignBytes(text, privateKey []byte) ([]byte, error)
- func ECCVerify(text []byte, signature []byte, key *ecdsa.PublicKey) bool
- func ECCVerifyBytes(text, signature, publicKey []byte) bool
- func EncryptKey(key *AccountKey, auth string) ([]byte, error)
- func ErrorLog(v ...interface{})
- func ErrorLogf(template string, v ...interface{})
- func FatalLogfAndExit(exitCode int, template string, v ...interface{})
- func FormatError(err error) string
- func GetCodecFromFileHash(hash string) (uint64, error)
- func GetLastLinesFromTrafficLog(path string, n uint64) []string
- func Int16ToBytes(n int16) []byte
- func Int64ToByte(n int64) []byte
- func IntToString(i int) string
- func IsVideoStream(hash string) bool
- func LoadTomlConfig(s interface{}, path string) error
- func LoadYamlConfig(s interface{}, path string) error
- func Log(v ...interface{})
- func Logf(template string, v ...interface{})
- func MergeByte(b ...[]byte) []byte
- func MergeBytes(a, b []byte) []byte
- func NewMnemonic() (string, error)
- func ParseTomlValue(data string) (interface{}, error)
- func RegisterReqToLogger(reqId int64, terminalId string) bool
- func RegisterReqToParentReq(reqId, parentId int64) bool
- func StringToInt(s string) (int, error)
- func Struct2Map(obj interface{}) map[string]interface{}
- func Uint16ToBytes(n uint16) []byte
- func Uint32ToBytes(n uint32) []byte
- func Uint64ToBytes(n uint64) []byte
- func Uint8ToBytes(n uint8) []byte
- func ValidateHash(hash string) bool
- func WarnLog(v ...interface{})
- func WriteKeyFile(file string, content []byte) error
- func WriteTomlConfig(data interface{}, filePath string) error
- type AccountKey
- type AutoCleanMap
- type AutoCleanUnsafeMap
- type CombinedLogger
- func (l *CombinedLogger) ErrorLog(v ...interface{})
- func (l *CombinedLogger) Log(level LogLevel, v ...interface{})
- func (l *CombinedLogger) LogDepth(level LogLevel, calldepth int, v ...interface{})
- func (l *CombinedLogger) SetEnablefile(b bool)
- func (l *CombinedLogger) SetEnablestd(b bool)
- func (l *CombinedLogger) SetLogLevel(lv LogLevel)
- type ErrUndefined
- type KeyStorePassphrase
- type LogLevel
- type LogMsg
- type Logger
- type MyUnsafeValue
- type MyValue
- type Url
Constants ¶
const ( VIDEO_CODEC = 0x72 // VIDEO_CODEC is separate from SDS_CODEC in order to identify the videos SDS_CODEC = 0x66 // codec of legacy file hash is cid.RAW. New file hash uses SDS_CODEC. VALID_CID_VERSION = 1 VALID_MH_TYPE = 27 VALID_MH_LENGTH = 20 )
const ( SIZE_OF_INT8 = 1 SIZE_OF_UINT8 = 1 SIZE_OF_INT16 = 2 // in byte SIZE_OF_UINT16 = 2 // in byte SIZE_OF_INT32 = 4 // in byte SIZE_OF_UINT32 = 4 // in byte SIZE_OF_INT64 = 8 // in byte SIZE_OF_UINT64 = 8 // in byte )
Variables ¶
Functions ¶
func AddRpcLogger ¶
func ByteToString ¶
func BytesToInt16 ¶
func BytesToInt64 ¶
func BytesToUInt32 ¶
func BytesToUInt64 ¶
func BytesToUint16 ¶
func CalcCRC32OfSlices ¶
func CalcFileCRC32 ¶
func CalcFileHash ¶
func CalcFileHashFromSlices ¶
func CalcFileKeccak ¶
func CalcFileMD5 ¶
func CalcHashBytes ¶
func CalcKeccakOfSplitFiles ¶
func CalcMD5OfSplitFiles ¶
func ChangePassword ¶
func ChangePassword(walletAddress, dir, auth string, key *AccountKey) error
ChangePassword
func CheckError ¶
CheckError TODO This is a bad way to call error log, as you cannot know where this method is called in your error log This give log line like this : [ERROR]2021/04/13 22:39:11 log.go:150: Fatal error: address 127.0.0.1: missing port in address it always refer to this file and this line If time allows, a better logging tool like "zerolog" can be used to replace these methods.
func CreateP2PKey ¶
CreateP2PKey creates a P2P key to be used by one of the SDS nodes, and saves the key data into the dir folder
func DebugLogf ¶
func DebugLogf(template string, v ...interface{})
DebugLog calls default logger and output debug log
func DebugLogfWithCalldepth ¶
DebugLog calls default logger and output debug log
func DetailLog ¶
func DetailLog(v ...interface{})
DetailLog calls default logger and output detail log
func DetailLogf ¶
func DetailLogf(template string, v ...interface{})
DetailLog calls default logger and output detail log
func DisableRpcLogger ¶
func DisableRpcLogger(id string)
func DumpTraffic ¶
func DumpTraffic(v ...interface{})
DumpTraffic Log calls default logger and output info log
func ECCSign ¶
func ECCSign(text []byte, prk *ecdsa.PrivateKey) ([]byte, error)
ECCSign signs the given text
func ECCSignBytes ¶
ECCSignBytes converts the private key bytes to an ecdsa.PrivateKey and then signs the given text
func ECCVerifyBytes ¶
ECCVerifyBytes converts the public key bytes to an ecdsa.PublicKey and then verifies the given signature
func EncryptKey ¶
func EncryptKey(key *AccountKey, auth string) ([]byte, error)
EncryptKey encrypts a key using the specified scrypt parameters into a json blob that can be decrypted later on.
func ErrorLogf ¶
func ErrorLogf(template string, v ...interface{})
ErrorLogf call default logger and output error log
func FatalLogfAndExit ¶
func FormatError ¶
func GetCodecFromFileHash ¶
func Int16ToBytes ¶
func Int64ToByte ¶
func IntToString ¶
func IsVideoStream ¶
func LoadTomlConfig ¶
func LoadYamlConfig ¶
func MergeBytes ¶
func NewMnemonic ¶
func ParseTomlValue ¶
func RegisterReqToLogger ¶
func RegisterReqToParentReq ¶
func StringToInt ¶
func Struct2Map ¶
func Struct2Map(obj interface{}) map[string]interface{}
func Uint16ToBytes ¶
func Uint32ToBytes ¶
func Uint64ToBytes ¶
func Uint8ToBytes ¶
func ValidateHash ¶
ValidateHash only validate the hash format, does NOT verify if the hash is created by certain content
func WriteKeyFile ¶
func WriteTomlConfig ¶
Types ¶
type AccountKey ¶
type AccountKey struct { Id uuid.UUID // Version 4 "random" for unique id not derived from key data // to simplify lookups we also store the address Address types.Address // The HD path to use to derive this key HdPath string // The mnemonic for the underlying HD wallet Mnemonic string // a nickname Name string // The bip39 passphrase for the underlying HD wallet Passphrase string // we only store privkey as pubkey/address can be derived from it // privkey in this struct is always in plaintext PrivateKey []byte }
func DecryptKey ¶
func DecryptKey(keyjson []byte, auth string) (*AccountKey, error)
DecryptKey decrypts a key from a json blob, returning the private key itself.
type AutoCleanMap ¶
type AutoCleanMap struct {
// contains filtered or unexported fields
}
func NewAutoCleanMap ¶
func NewAutoCleanMap(delay time.Duration) *AutoCleanMap
func (*AutoCleanMap) Delete ¶
func (m *AutoCleanMap) Delete(key interface{})
func (*AutoCleanMap) HashKey ¶
func (m *AutoCleanMap) HashKey(key interface{}) bool
func (*AutoCleanMap) Load ¶
func (m *AutoCleanMap) Load(key interface{}) (interface{}, bool)
func (*AutoCleanMap) Store ¶
func (m *AutoCleanMap) Store(key, value interface{})
type AutoCleanUnsafeMap ¶
type AutoCleanUnsafeMap struct {
// contains filtered or unexported fields
}
func NewAutoCleanUnsafeMap ¶
func NewAutoCleanUnsafeMap(delay time.Duration) *AutoCleanUnsafeMap
func (*AutoCleanUnsafeMap) Delete ¶
func (m *AutoCleanUnsafeMap) Delete(key interface{})
func (*AutoCleanUnsafeMap) HashKey ¶
func (m *AutoCleanUnsafeMap) HashKey(key interface{}) bool
func (*AutoCleanUnsafeMap) Len ¶
func (m *AutoCleanUnsafeMap) Len() int
func (*AutoCleanUnsafeMap) Load ¶
func (m *AutoCleanUnsafeMap) Load(key interface{}) (interface{}, bool)
func (*AutoCleanUnsafeMap) Store ¶
func (m *AutoCleanUnsafeMap) Store(key, value interface{})
type CombinedLogger ¶
type CombinedLogger struct {
// contains filtered or unexported fields
}
var MyLogger *CombinedLogger
var TrafficLogger *CombinedLogger
func NewDefaultLogger ¶
func NewDefaultLogger(filepath string, enableStd, enableFile bool) *CombinedLogger
func NewLogger ¶
func NewLogger(filepath string, enableStd, enableFile bool) *CombinedLogger
func NewTrafficLogger ¶
func NewTrafficLogger(filePath string, enableStd, enableFile bool) *CombinedLogger
func (*CombinedLogger) ErrorLog ¶
func (l *CombinedLogger) ErrorLog(v ...interface{})
func (*CombinedLogger) Log ¶
func (l *CombinedLogger) Log(level LogLevel, v ...interface{})
func (*CombinedLogger) LogDepth ¶
func (l *CombinedLogger) LogDepth(level LogLevel, calldepth int, v ...interface{})
func (*CombinedLogger) SetEnablefile ¶
func (l *CombinedLogger) SetEnablefile(b bool)
func (*CombinedLogger) SetEnablestd ¶
func (l *CombinedLogger) SetEnablestd(b bool)
type ErrUndefined ¶
type ErrUndefined int32
ErrUndefined
func (ErrUndefined) Error ¶
func (e ErrUndefined) Error() string
type KeyStorePassphrase ¶
func GetKeyStorePassphrase ¶
func GetKeyStorePassphrase(keysDirPath string) KeyStorePassphrase
func (KeyStorePassphrase) StoreKey ¶
func (ks KeyStorePassphrase) StoreKey(filename string, key *AccountKey, auth string) error
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func GetRpcLoggerByReqId ¶
func (*Logger) SetEnabled ¶
type MyUnsafeValue ¶
type MyUnsafeValue struct {
// contains filtered or unexported fields
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
math
Package math provides integer math utilities.
|
Package math provides integer math utilities. |
rlp
Package rlp implements the RLP serialization format.
|
Package rlp implements the RLP serialization format. |
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
|
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202. |