models

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: ISC, MIT Imports: 11 Imported by: 48

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddColumn

func AddColumn(dbMap *gorp.DbMap, db string, table string, columnToAdd string,
	dataSpec string, colAfter string, defaultQry string)

AddColumn checks if a column exists and adds it if it doesn't

func DecodeHashList

func DecodeHashList(hashList HashList) ([]chainhash.Hash, error)

DecodeHashList attempts to decode each hash string in the given HashList, returning a non-nil error if any string in the list is not a valid hashes.

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func GetDbMap

func GetDbMap(APISecret, baseURL, user, password, hostname, port, database string) *gorp.DbMap

func GetUserCount

func GetUserCount(dbMap *gorp.DbMap) int64

GetUserCount gives a count of all users

func GetUserCountActive

func GetUserCountActive(dbMap *gorp.DbMap) int64

GetUserCountActive gives a count of all users who have submitted an address

func GetUserMax

func GetUserMax(dbMap *gorp.DbMap) int64

GetUserMax gives the last userid

func InsertEmailChange

func InsertEmailChange(dbMap *gorp.DbMap, emailChange *EmailChange) error

func InsertLowFeeTicket

func InsertLowFeeTicket(dbMap *gorp.DbMap, lowFeeTicket *LowFeeTicket) error

InsertLowFeeTicket inserts a user into the DB

func InsertPasswordReset

func InsertPasswordReset(dbMap *gorp.DbMap, passwordReset *PasswordReset) error

func InsertUser

func InsertUser(dbMap *gorp.DbMap, user *User) error

InsertUser inserts a user into the DB

func SetUserAPIToken

func SetUserAPIToken(dbMap *gorp.DbMap, APISecret string, baseURL string,
	id int64) (string, error)

SetUserAPIToken generates and saves a unique API Token for a user.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

func ValidateHashList

func ValidateHashList(hashList HashList) error

ValidateHashList ensures that all strings in the HashList are valid Decred hashes. If all are valid, the returned error will be nil.

Types

type EmailChange

type EmailChange struct {
	Id       int64 `db:"EmailChangeID"`
	UserId   int64
	NewEmail string
	Token    string
	Created  int64
	Expires  int64
}

type HashList

type HashList []string

HashList represents a slice of hash strings.

func (HashList) ToStringSlice

func (hashList HashList) ToStringSlice() []string

ToStringSlice satisfies gorp's internal "stringer" interface used by expandSliceArgs. It is a trivial conversion since the underlying type of HashList is a []string, but if a HashList is provided to a gorp query/transaction then ToStringSlice must be implemented to obtain the []string type in expandSliceArgs.

type LowFeeTicket

type LowFeeTicket struct {
	Id            int64 `db:"LowFeeTicketID"`
	AddedByUid    int64
	TicketAddress string
	TicketHash    string
	TicketExpiry  int64
	Voted         int64
	Created       int64
	Expires       int64
}

func GetVotableLowFeeTickets

func GetVotableLowFeeTickets(dbMap *gorp.DbMap) ([]LowFeeTicket, error)

type PasswordReset

type PasswordReset struct {
	Id      int64 `db:"PasswordResetID"`
	UserId  int64
	Token   string
	Created int64
	Expires int64
}

type Session

type Session struct {
	Id      int64 `db:"SessionID"`
	Token   string
	Data    []byte
	UserId  int64
	Created int64
	Expires int64
}

type User

type User struct {
	Id               int64 `db:"UserId"`
	Email            string
	Username         string
	Password         []byte
	MultiSigAddress  string
	MultiSigScript   string
	PoolPubKeyAddr   string
	UserPubKeyAddr   string
	UserFeeAddr      string
	HeightRegistered int64
	EmailVerified    int64
	EmailToken       string
	APIToken         string
	VoteBits         int64
	VoteBitsVersion  int64
}

func GetAllCurrentMultiSigScripts

func GetAllCurrentMultiSigScripts(dbMap *gorp.DbMap) ([]User, error)

func GetUserByEmail

func GetUserByEmail(dbMap *gorp.DbMap, email string) (user *User)

func GetUserById

func GetUserById(dbMap *gorp.DbMap, id int64) (user *User, err error)

func UpdateUserByID

func UpdateUserByID(dbMap *gorp.DbMap, id int64, multiSigAddr string,
	multiSigScript string, poolPubKeyAddr string, userPubKeyAddr string,
	userFeeAddr string, height int64) (user *User)

UpdateUserByID updates a user, specified by id, in the DB with a new multiSigAddr, multiSigScript, multiSigScript, pool pubkey address, user pub key address, and fee address. Unchanged are the user's ID, email, username and password.

func (*User) HashPassword

func (user *User) HashPassword(password string)

type UserToken

type UserToken [userTokenSize]byte

UserToken is a token used in user registration, and email and password changes.

func NewUserToken

func NewUserToken() (ut UserToken)

NewUserToken creates a new random UserToken.

func UserTokenFromStr

func UserTokenFromStr(token string) (UserToken, error)

UserTokenFromStr attempts to decode the token string into a UserToken.

func (UserToken) String

func (ut UserToken) String() string

String returns the hexadecimal encoding of the token bytes.

Jump to

Keyboard shortcuts

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