services

package
v0.0.0-...-9dc0c09 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash         = errors.New("invalid format")
	ErrIncompatibleVersion = errors.New("incompatible version of argon2")
)

inspired from: https://gist.github.com/alexedwards/34277fae0f48abe36822b375f0f6a621

View Source
var (
	ErrMarshalTx       = errors.New("marshal error")
	ErrTxAlreadyInPool = errors.New("transaction is already in pool")
)
View Source
var ALLOWED_ALGORITHMS = []string{"HS256"}

Functions

func ValidateAccount

func ValidateAccount(fl validator.FieldLevel) bool

func ValidateEnum

func ValidateEnum(fl validator.FieldLevel) bool

func ValidateHash

func ValidateHash(fl validator.FieldLevel) bool

func ValidatePassword

func ValidatePassword(fl validator.FieldLevel) bool

Types

type BlockService

type BlockService interface {
	GetNextBlocksFromHash(models.Hash) ([]models.Block, error)
	Mine(context.Context, models.PendingBlock) (*models.Block, error)

	ThisNodeMiningAddress() models.Account
}

type Enum

type Enum interface {
	IsValid() bool
}

type EthKeystoreService

type EthKeystoreService struct {
	// contains filtered or unexported fields
}

func NewEthKeystore

func NewEthKeystore(keystoreDataDirPath string) (*EthKeystoreService, error)

func (*EthKeystoreService) NewKeystoreAccount

func (k *EthKeystoreService) NewKeystoreAccount(password string) (common.Address, error)

type FileBlockService

type FileBlockService struct {
	// contains filtered or unexported fields
}

func NewFileBlockService

func NewFileBlockService(
	transactionFilePath string,
	miningComplexity uint32,
	miningAddress models.Account,
) (*FileBlockService, error)

func (*FileBlockService) GetNextBlocksFromHash

func (a *FileBlockService) GetNextBlocksFromHash(from models.Hash) ([]models.Block, error)

func (*FileBlockService) Mine

Mine mines a pending block meaning that it'll try to find a valid nonce so it can create a block in the blockchain

func (*FileBlockService) ThisNodeMiningAddress

func (a *FileBlockService) ThisNodeMiningAddress() models.Account

type FileTransactionService

type FileTransactionService struct {
	// contains filtered or unexported fields
}

func NewFileTransactionService

func NewFileTransactionService() *FileTransactionService

NewFileTransactionService default constructor

func (*FileTransactionService) AddPendingTx

func (a *FileTransactionService) AddPendingTx(tx models.Transaction) error

AddPendingTx adds a transaction to the pool

func (*FileTransactionService) GetPendingTxs

GetPendingTxs get pending transactions

func (*FileTransactionService) RemovePendingTx

func (a *FileTransactionService) RemovePendingTx(id models.TransactionId)

RemovePendingTx remove transaction from pool

func (*FileTransactionService) RemovePendingTxs

func (a *FileTransactionService) RemovePendingTxs(ids []models.TransactionId)

RemovePendingTxs remove transactions from pool

type JwtService

type JwtService struct {
	// contains filtered or unexported fields
}

func NewJwtService

func NewJwtService(verifyingConf VerifyingConf, signingConf SigningConf) (*JwtService, error)

func (*JwtService) PrivateKeyId

func (j *JwtService) PrivateKeyId() string

func (*JwtService) PrivateKeyPath

func (j *JwtService) PrivateKeyPath() string

func (*JwtService) SignToken

func (j *JwtService) SignToken(content interface{}) (string, error)

SignToken Sign token with private key passed at the initialisation of the service including the payload passed as content parameter

func (*JwtService) VerifyToken

func (j *JwtService) VerifyToken(signedToken string) (jwt.Token, error)

VerifyToken check if token is valid according to public key info expsed by jwks

type KeystoreService

type KeystoreService interface {
	NewKeystoreAccount(password string) (common.Address, error)
}

fine to leave eth object as we are not planning on implementing another keystore only for test/muck purposes

type Name

type Name string

Name toml specific struct

type PasswordService

type PasswordService struct {
	// contains filtered or unexported fields
}

func NewDefaultPasswordService

func NewDefaultPasswordService() PasswordService

func NewPasswordService

func NewPasswordService(memory uint32, iterations uint32, parallelism uint8, saltLength uint32, keyLength uint32) PasswordService

func (PasswordService) ComparePasswordAndHash

func (c PasswordService) ComparePasswordAndHash(password, encodedHash string) (match bool, err error)

func (PasswordService) GenerateHash

func (c PasswordService) GenerateHash(password string) (hash string, err error)

type SigningConf

type SigningConf struct {
	// contains filtered or unexported fields
}

func NewSigningConf

func NewSigningConf(algo string, audience string, domain string, expiresInHours int, issuer string, privateKeyPath string, privateKeyId string) SigningConf

type TransactionService

type TransactionService interface {
	AddPendingTx(models.Transaction) error
	GetPendingTxs() map[models.TransactionId]models.Transaction
	RemovePendingTx(models.TransactionId)
	RemovePendingTxs([]models.TransactionId)
}

type UserFromDB

type UserFromDB struct {
	Nodes map[Name]struct {
		Hash string
	}
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(userDatabasePath string) (*UserService, error)

NewUserService initiate the user service

func (*UserService) Get

func (u *UserService) Get(userName string) (*models.User, error)

Get user if found, nil otherwise

func (*UserService) List

func (u *UserService) List() (map[Name]models.User, error)

List all users, empty array otherwise

type ValidatorService

type ValidatorService struct{}

func (ValidatorService) AddValidators

func (v ValidatorService) AddValidators()

type VerifyingConf

type VerifyingConf struct {
	// contains filtered or unexported fields
}

func NewVerifyingConf

func NewVerifyingConf(jwksUrl string, jkmsRefreshCacheIntervalInMin int, jkmsRefreshCacheRateLimitInMin int, jkmsRefreshCacheTimeoutInSec int) VerifyingConf

Jump to

Keyboard shortcuts

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