Documentation ¶
Index ¶
- func AddressFromEcdsaPrivateKey(privateKey *ecdsa.PrivateKey) (common.Address, error)
- func AddressFromEcdsaPrivateKeyString(privateKeyStr string) (common.Address, error)
- func BuildApiKey(appContract string, consumerPrivateKeyText string) (string, error)
- func BuildBillingKey(appContract string, ownerPrivateKeyText string) (string, error)
- func BuildPersonalSignMessage(message string) string
- func EcdsaPrivateKeyFromString(privateKeyStr string) (*ecdsa.PrivateKey, error)
- func GetAddrByApiAuthKey(contract string, apiKey *types.ApiAuthKey) (common.Address, error)
- func GetAddrByApiKey(contract, apiKey string) (common.Address, error)
- func GetAddrByBillingAuthKey(billingKey *types.BillingAuthKey) (common.Address, error)
- func GetAddrByBillingKey(billingKey string) (common.Address, error)
- func GracefulShutdown(wg *sync.WaitGroup, cancel context.CancelFunc)
- func IsInterfaceValNil(i interface{}) bool
- func IsZeroAddress(iaddress interface{}) bool
- func KLock(key MutexKey)
- func KUnlock(key MutexKey)
- func MustNewEthClientFromViper(customOpt ...func(*web3go.ClientOption)) *web3go.Client
- func ParseApiKey(apiKey string) (*types.ApiAuthKey, error)
- func ParseBillingKey(billingKey string) (*types.BillingAuthKey, error)
- func PersonalSign(message string, privateKey *ecdsa.PrivateKey) (string, common.Hash, error)
- func RecoverAddress(message string, signature string) (string, error)
- func StartAndGracefulShutdown(run func(ctx context.Context, wg *sync.WaitGroup))
- type AuthKeyManager
- type ExpirableLruCache
- type KMutex
- type MutexKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressFromEcdsaPrivateKey ¶
func AddressFromEcdsaPrivateKey(privateKey *ecdsa.PrivateKey) (common.Address, error)
func BuildApiKey ¶
BuildApiKey utility function to help build API key with specified APP contract address and consumer private key text.
func BuildBillingKey ¶
BuildBillingKey utility function to help build billing key with specified APP contract address and its owner private key text.
func EcdsaPrivateKeyFromString ¶
func EcdsaPrivateKeyFromString(privateKeyStr string) (*ecdsa.PrivateKey, error)
func GetAddrByApiAuthKey ¶
func GetAddrByBillingAuthKey ¶
func GetAddrByBillingAuthKey(billingKey *types.BillingAuthKey) (common.Address, error)
func GracefulShutdown ¶
func GracefulShutdown(wg *sync.WaitGroup, cancel context.CancelFunc)
GracefulShutdown supports to clean up goroutines after termination signal captured.
func IsInterfaceValNil ¶
func IsInterfaceValNil(i interface{}) bool
Helper function to check if interface value is nil, since "i == nil" checks nil interface case only. Refer to https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1 for more details.
func IsZeroAddress ¶
func IsZeroAddress(iaddress interface{}) bool
IsZeroAddress validate if it's a 0 address
func MustNewEthClientFromViper ¶
func MustNewEthClientFromViper(customOpt ...func(*web3go.ClientOption)) *web3go.Client
func ParseApiKey ¶
func ParseApiKey(apiKey string) (*types.ApiAuthKey, error)
func ParseBillingKey ¶
func ParseBillingKey(billingKey string) (*types.BillingAuthKey, error)
func PersonalSign ¶
Returns a signature string
func StartAndGracefulShutdown ¶
StartAndGracefulShutdown starts to run the specified task in a goroutine and wait for termination signal to shutdown gracefully.
Note, this method is not suitable for any non-blocking task that release resources in defer way.
Types ¶
type AuthKeyManager ¶
type AuthKeyManager struct {
// contains filtered or unexported fields
}
func NewAuthKeyManager ¶
func NewAuthKeyManager() *AuthKeyManager
func (*AuthKeyManager) GetAddrByApiAuthKey ¶
func (m *AuthKeyManager) GetAddrByApiAuthKey(contract string, apiKey *types.ApiAuthKey) (common.Address, error)
func (*AuthKeyManager) GetAddrByBillingAuthKey ¶
func (m *AuthKeyManager) GetAddrByBillingAuthKey(billingKey *types.BillingAuthKey) (common.Address, error)
type ExpirableLruCache ¶
type ExpirableLruCache struct {
// contains filtered or unexported fields
}
ExpirableLruCache naive implementation of LRU cache with fixed TTL expiration duration. This cache uses a lazy eviction policy, by which the expired entry will be purged when it's being looked up.
func NewExpirableLruCache ¶
func NewExpirableLruCache(size int, ttl time.Duration) (*ExpirableLruCache, error)
func (*ExpirableLruCache) Add ¶
func (c *ExpirableLruCache) Add(key, value interface{}) bool
Add adds a value to the cache. Returns true if an eviction occurred.
func (*ExpirableLruCache) Get ¶
func (c *ExpirableLruCache) Get(key interface{}) (interface{}, bool)
Get looks up a key's value from the cache. Will purge the entry and return nil if the entry expired.