repository

package
v0.0.0-...-b370a20 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateStats

func UpdateStats(paymentRepo PaymentRepo, workRepo WorkRepo) error

Types

type PaymentRepo

type PaymentRepo interface {
	BatchCreateSendRequests(tx *gorm.DB, sendRequests []serializableModels.SendRequest) error
	GetPendingPayments(tx *gorm.DB) ([]serializableModels.SendRequest, error)
	SetBlockHash(tx *gorm.DB, sendId string, blockHash string) error
	GetTotalPaidBanano() (float64, error)
}

type PaymentService

type PaymentService struct {
	Db *gorm.DB
}

func NewPaymentService

func NewPaymentService(db *gorm.DB) *PaymentService

func (*PaymentService) BatchCreateSendRequests

func (s *PaymentService) BatchCreateSendRequests(tx *gorm.DB, sendRequests []serializableModels.SendRequest) error

Create payments in database

func (*PaymentService) GetPendingPayments

func (s *PaymentService) GetPendingPayments(tx *gorm.DB) ([]serializableModels.SendRequest, error)

Get all payments with null block hash

func (*PaymentService) GetTotalPaidBanano

func (s *PaymentService) GetTotalPaidBanano() (float64, error)

Get total paid sum

func (*PaymentService) SetBlockHash

func (s *PaymentService) SetBlockHash(tx *gorm.DB, sendId string, blockHash string) error

Update payment with block hash

type ServicesResult

type ServicesResult struct {
	TotalRequests  int    `json:"total_requests"`
	ServiceName    string `json:"service_name"`
	ServiceWebsite string `json:"service_website"`
}

type Top10Result

type Top10Result struct {
	BanAddress string `json:"ban_address"`
	TotalRaw   string `json:"total_raw"`
	TotalBan   string `json:"total_ban"`
}

type UnpaidSumResult

type UnpaidSumResult struct {
	DifficultySum int `json:"difficulty_sum"`
}

type UnpaidWorkResult

type UnpaidWorkResult struct {
	UnpaidSumResult
	UnpaidCount int       `json:"unpaid_count"`
	ProvidedBy  uuid.UUID `json:"provided_by"`
	BanAddress  string    `json:"ban_address"`
}

type UserRepo

type UserRepo interface {
	CreateUser(userInput *model.UserInput, doEmail bool) (*models.User, error)
	SendConfirmEmailEmail(userEmail string, userType models.UserType, actuallyDoEmail bool) error
	CreateMockUsers() error
	DeleteUser(id uuid.UUID) error
	GetUser(id *uuid.UUID, email *string) (*models.User, error)
	GetAllUsers() ([]*models.User, error)
	Authenticate(loginInput *model.LoginInput) *models.User
	VerifyEmailToken(verifyEmail *model.VerifyEmailInput) (bool, error)
	VerifyService(verifyService *model.VerifyServiceInput) (bool, error)
	GenerateResetPasswordRequest(resetPasswordInput *model.ResetPasswordInput, doEmail bool) (string, error)
	GenerateServiceToken() string
	CreateService(email string, serviceName string, serviceWebsite string) (string, error)
	GetNumberServices() (int64, error)
	ChangePassword(email string, userInput *model.ChangePasswordInput) error
}

type UserService

type UserService struct {
	Db *gorm.DB
}

func NewUserService

func NewUserService(db *gorm.DB) *UserService

func (*UserService) Authenticate

func (s *UserService) Authenticate(loginInput *model.LoginInput) *models.User

Compare password to hashed password, return true if match false otherwise

func (*UserService) ChangePassword

func (s *UserService) ChangePassword(email string, userInput *model.ChangePasswordInput) error

func (*UserService) CreateMockUsers

func (s *UserService) CreateMockUsers() error

func (*UserService) CreateService

func (s *UserService) CreateService(email string, serviceName string, serviceWebsite string) (string, error)

func (*UserService) CreateUser

func (s *UserService) CreateUser(userInput *model.UserInput, doEmail bool) (*models.User, error)

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(id uuid.UUID) error

func (*UserService) GenerateResetPasswordRequest

func (s *UserService) GenerateResetPasswordRequest(resetPasswordInput *model.ResetPasswordInput, doEmail bool) (string, error)

func (*UserService) GenerateServiceToken

func (s *UserService) GenerateServiceToken() string

Generate a service token (for services to request work)

func (*UserService) GetAllUsers

func (s *UserService) GetAllUsers() ([]*models.User, error)

func (*UserService) GetNumberServices

func (s *UserService) GetNumberServices() (int64, error)

func (*UserService) GetUser

func (s *UserService) GetUser(id *uuid.UUID, email *string) (*models.User, error)

func (*UserService) SendConfirmEmailEmail

func (s *UserService) SendConfirmEmailEmail(userEmail string, userType models.UserType, actuallyDoEmail bool) error

func (*UserService) VerifyEmailToken

func (s *UserService) VerifyEmailToken(verifyEmail *model.VerifyEmailInput) (bool, error)

func (*UserService) VerifyService

func (s *UserService) VerifyService(verifyService *model.VerifyServiceInput) (bool, error)

type WorkMessage

type WorkMessage struct {
	BlockAward           bool   `json:"block_award"`
	RequestedByEmail     string `json:"requestedByEmail"`
	ProvidedByEmail      string `json:"providedByEmail"`
	Hash                 string `json:"hash"`
	Result               string `json:"result"`
	DifficultyMultiplier int    `json:"difficulty_multiplier"`
	Precache             bool   `json:"precache"`
}

type WorkRepo

type WorkRepo interface {
	SaveOrUpdateWorkResult(workMessage WorkMessage) (*models.WorkResult, error)
	GetWorkRecord(hash string) (*models.WorkResult, error)
	StatsWorker(statsChan <-chan WorkMessage, blockAwardedChan *chan serializableModels.ClientMessage)
	GetUnpaidWorkSumForUser(email string) (int, error)
	GetUnpaidWorkSum() (int, error)
	RetrieveWorkFromCache(hash string, difficultyMultiplier int) (string, error)
	GetUnpaidWorkCount(tx *gorm.DB) ([]UnpaidWorkResult, error)
	GetUnpaidWorkCountAndMarkAllPaid(tx *gorm.DB) ([]UnpaidWorkResult, error)
	GetTopContributors(limit int) ([]Top10Result, error)
	GetServiceStats() ([]ServicesResult, error)
}

type WorkService

type WorkService struct {
	Db *gorm.DB
	// contains filtered or unexported fields
}

func NewWorkService

func NewWorkService(db *gorm.DB, userRepo UserRepo) *WorkService

func (*WorkService) GetServiceStats

func (s *WorkService) GetServiceStats() ([]ServicesResult, error)

func (*WorkService) GetTopContributors

func (s *WorkService) GetTopContributors(limit int) ([]Top10Result, error)

func (*WorkService) GetUnpaidWorkCount

func (s *WorkService) GetUnpaidWorkCount(tx *gorm.DB) ([]UnpaidWorkResult, error)

func (*WorkService) GetUnpaidWorkCountAndMarkAllPaid

func (s *WorkService) GetUnpaidWorkCountAndMarkAllPaid(tx *gorm.DB) ([]UnpaidWorkResult, error)

func (*WorkService) GetUnpaidWorkSum

func (s *WorkService) GetUnpaidWorkSum() (int, error)

Summate the difficulty of unpaid works for all users

func (*WorkService) GetUnpaidWorkSumForUser

func (s *WorkService) GetUnpaidWorkSumForUser(email string) (int, error)

func (*WorkService) GetWorkRecord

func (s *WorkService) GetWorkRecord(hash string) (*models.WorkResult, error)

func (*WorkService) RetrieveWorkFromCache

func (s *WorkService) RetrieveWorkFromCache(hash string, difficultyMultiplier int) (string, error)

func (*WorkService) SaveOrUpdateWorkResult

func (s *WorkService) SaveOrUpdateWorkResult(workMessage WorkMessage) (*models.WorkResult, error)

func (*WorkService) StatsWorker

func (s *WorkService) StatsWorker(statsChan <-chan WorkMessage, blockAwardedChan *chan serializableModels.ClientMessage)

Jump to

Keyboard shortcuts

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