models

package
v0.0.0-...-c387957 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const PG_USER_TYPE_NAME = "user_type"

The name of the type as it's stored in postgres

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveChannelObject

type ActiveChannelObject struct {
	BlockAward           bool
	RequesterEmail       string
	RequestID            string
	Hash                 string
	DifficultyMultiplier int
	Precache             bool
	Chan                 chan []byte
}

type Base

type Base struct {
	ID        uuid.UUID `json:"_id" gorm:"primaryKey;autoIncrement:false"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Base contains common columns for all tables

func (*Base) AfterUpdate

func (base *Base) AfterUpdate(tx *gorm.DB) error

AfterUpdate will update the Base struct after every update

func (*Base) BeforeCreate

func (base *Base) BeforeCreate(tx *gorm.DB) error

BeforeCreate will set Base struct before every insert

type Payment

type Payment struct {
	Base
	BlockHash *string            `json:"block_hash" gorm:"uniqueIndex"`
	SendId    string             `json:"send_id" gorm:"uniqueIndex;not null"`
	Amount    uint               `json:"amount"`
	SendJson  models.SendRequest `json:"send_json" gorm:"type:jsonb;not null"`
	PaidTo    uuid.UUID          `json:"user_id" gorm:"not null"`
}

Store the payment request to users in the database

type StatsSingleton

type StatsSingleton struct {
	Stats *model.Stats
}

func GetStatsInstance

func GetStatsInstance() *StatsSingleton

type SyncArray

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

SyncArray builds an thread-safe array with some handy methods

func NewSyncArray

func NewSyncArray() *SyncArray

func (*SyncArray) Delete

func (r *SyncArray) Delete(requestID string)

Removes specified hash - synchronized

func (*SyncArray) Exists

func (r *SyncArray) Exists(requestID string) bool

See if element exists

func (*SyncArray) Get

func (r *SyncArray) Get(requestID string) *ActiveChannelObject

Gets a value from the map - synchronized

func (*SyncArray) HashExists

func (r *SyncArray) HashExists(hash string) bool

func (*SyncArray) IndexOf

func (r *SyncArray) IndexOf(requestID string) int

func (*SyncArray) Len

func (r *SyncArray) Len() int

func (*SyncArray) Put

func (r *SyncArray) Put(value *ActiveChannelObject)

Put value into map - synchronized

type User

type User struct {
	Base
	Type               UserType `gorm:"type:user_type;not null"`
	Email              string   `json:"email" gorm:"uniqueIndex;not null"`
	Password           string   `json:"password" gorm:"not null"`
	EmailVerified      bool     `json:"emailVerfied" gorm:"default:false;not null"`
	ServiceName        *string  `json:"serviceName"`
	ServiceWebsite     *string  `json:"serviceWebsite"`
	CanRequestWork     bool     `json:"canRequestWork" gorm:"default:false;not null"`
	InvalidResultCount int      `json:"invalidResultCount" gorm:"default:0;not null"`
	// For reward payments
	BanAddress *string `json:"banAddress"`
	// The work this user provider
	WorkResults        []WorkResult `gorm:"foreignKey:ProvidedBy"`
	LastProvidedWorkAt *time.Time   `json:"lastProvidedWorkAt"`
	// The work this user has requested
	WorkRequests        []WorkResult `gorm:"foreignKey:RequestedBy"`
	LastRequestedWorkAt *time.Time   `json:"lastRequestedWorkAt"`
	// Payments sent to this user
	Payments []Payment `gorm:"foreignKey:PaidTo"`
	// Banned
	Banned bool `json:"banned" gorm:"default:false;not null"`
}

type UserType

type UserType string
const (
	PROVIDER  UserType = "PROVIDER"
	REQUESTER UserType = "REQUESTER"
)

func (*UserType) Scan

func (ct *UserType) Scan(value interface{}) error

func (UserType) Value

func (ct UserType) Value() (driver.Value, error)

type WorkResult

type WorkResult struct {
	Base
	Hash                 string    `json:"hash" gorm:"uniqueIndex;not null"`
	DifficultyMultiplier int       `json:"difficulty_multiplier"`
	Result               string    `json:"result" gorm:"not null"`
	Awarded              bool      `json:"awarded" gorm:"default:false;not null"` // Whether or not this has been awarded
	ProvidedBy           uuid.UUID `json:"providedBy" gorm:"not null"`
	RequestedBy          uuid.UUID `json:"requestedBy" gorm:"not null"`
	Precache             bool      `json:"precache" gorm:"default:false;not null"`
}

Jump to

Keyboard shortcuts

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