controllers

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: 34 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// MaxUsers is the maximum number of users supported by a voting service.
	// This is an artificial limit and can be increased by adjusting the
	// ticket/fee address indexes above 10000.
	MaxUsers = 10000
)

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

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

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.

Types

type ApiController

type ApiController struct {
	system.Controller
}

type BySpentByHeight

type BySpentByHeight []TicketInfoHistoric

BySpentByHeight type implements sort.Sort for types with a SpentByHeight field, namely TicketInfoHistoric, the type for voted/missed/expired tickets.

func (BySpentByHeight) Len

func (a BySpentByHeight) Len() int

func (BySpentByHeight) Less

func (a BySpentByHeight) Less(i, j int) bool

func (BySpentByHeight) Swap

func (a BySpentByHeight) Swap(i, j int)

type ByTicketHeight

type ByTicketHeight []TicketInfo

ByTicketHeight type implements sort.Sort for types with a TicketHeight field. This includes all valid tickets, including spend tickets.

func (ByTicketHeight) Len

func (a ByTicketHeight) Len() int

func (ByTicketHeight) Less

func (a ByTicketHeight) Less(i, j int) bool

func (ByTicketHeight) Swap

func (a ByTicketHeight) Swap(i, j int)

type CaptchaHandler

type CaptchaHandler struct {
	ImgWidth  int
	ImgHeight int
}

type Config

type Config struct {
	AdminIPs             []string
	AdminUserIDs         []string
	APISecret            string
	BaseURL              string
	ClosePool            bool
	ClosePoolMsg         string
	PoolEmail            string
	PoolFees             float64
	PoolLink             string
	RealIPHeader         string
	MaxVotedTickets      int
	Description          string
	Designation          string
	APIVersionsSupported []int
	FeeXpub              *hdkeychain.ExtendedKey
	StakepooldServers    *stakepooldclient.StakepooldManager
	EmailSender          email.Sender
	VotingXpub           *hdkeychain.ExtendedKey

	NetParams *chaincfg.Params
}

type MainController

type MainController struct {
	// embed type for c.Env[""] context and ExecuteTemplate helpers
	system.Controller

	Cfg *Config
	// contains filtered or unexported fields
}

MainController is the wallet RPC controller type. Its methods include the route handlers.

func NewMainController

func NewMainController(cfg *Config) (*MainController, error)

NewMainController is the constructor for the entire controller routing.

func (*MainController) API

func (controller *MainController) API(c web.C, r *http.Request) *system.APIResponse

API is the main frontend that handles all API requests.

func (*MainController) APIAddress

func (controller *MainController) APIAddress(c web.C, r *http.Request) ([]string, codes.Code, string, error)

APIAddress is the API version of AddressPost

func (*MainController) APIPurchaseInfo

func (controller *MainController) APIPurchaseInfo(c web.C,
	r *http.Request) (*poolapi.PurchaseInfo, codes.Code, string, error)

APIPurchaseInfo fetches and returns the user's info or an error

func (*MainController) APIStats

func (controller *MainController) APIStats(c web.C,
	r *http.Request) (*poolapi.Stats, codes.Code, string, error)

APIStats is an API version of the stats page

func (*MainController) APIVoting

func (controller *MainController) APIVoting(c web.C, r *http.Request) ([]string, codes.Code, string, error)

APIVotingPost is the API version of VotingPost

func (*MainController) Address

func (controller *MainController) Address(c web.C, r *http.Request) (string, int)

Address renders the address page.

func (*MainController) AddressPost

func (controller *MainController) AddressPost(c web.C, r *http.Request) (string, int)

AddressPost is address form submit route.

func (*MainController) AdminStatus

func (controller *MainController) AdminStatus(c web.C, r *http.Request) (string, int)

AdminStatus renders the status page.

func (*MainController) AdminTickets

func (controller *MainController) AdminTickets(c web.C, r *http.Request) (string, int)

AdminTickets renders the administrative tickets page. Tickets purchased with an incorrect VSP fee will be listed on this page. Admin users can choose whether the pool should vote these tickets or not.

func (*MainController) AdminTicketsPost

func (controller *MainController) AdminTicketsPost(c web.C, r *http.Request) (string, int)

AdminTicketsPost validates and processes the form posted from AdminTickets.

func (*MainController) CalcEstimatedTicketExpiry

func (controller *MainController) CalcEstimatedTicketExpiry() time.Time

CalcEstimatedTicketExpiry returns a time.Time reflecting the estimated time that the ticket will expire. A safety margin of 5% padding is applied to ensure the ticket is not removed prematurely. XXX we should really be using the actual expiry height of the ticket instead of an estimated time but the stakepool doesn't have a way to retrieve that information yet.

func (*MainController) CaptchaServe

func (controller *MainController) CaptchaServe(c web.C, w http.ResponseWriter, r *http.Request)

func (*MainController) CaptchaVerify

func (controller *MainController) CaptchaVerify(c web.C, w http.ResponseWriter, r *http.Request)

func (*MainController) CheckAndResetUserVoteBits

func (controller *MainController) CheckAndResetUserVoteBits(dbMap *gorp.DbMap) (map[int64]*models.User, error)

CheckAndResetUserVoteBits reset users VoteBits if the VoteVersion has changed or if the stored VoteBits are somehow invalid.

func (*MainController) EmailUpdate

func (controller *MainController) EmailUpdate(c web.C, r *http.Request) (string, int)

EmailUpdate validates the passed token and updates the user's email address.

func (*MainController) EmailVerify

func (controller *MainController) EmailVerify(c web.C, r *http.Request) (string, int)

EmailVerify renders the email verification page.

func (*MainController) Error

func (controller *MainController) Error(c web.C, r *http.Request) (string, int)

Error renders the error page.

func (*MainController) FeeAddressForUserID

func (controller *MainController) FeeAddressForUserID(uid int) (dcrutil.Address,
	error)

FeeAddressForUserID generates a unique payout address per used ID for fees for an individual pool user.

func (*MainController) Index

func (controller *MainController) Index(c web.C, r *http.Request) (string, int)

Index renders the home page.

func (*MainController) IsValidVoteBits

func (controller *MainController) IsValidVoteBits(userVoteBits uint16) bool

IsValidVoteBits returns an error if voteBits are not valid for agendas

func (*MainController) Login

func (controller *MainController) Login(c web.C, r *http.Request) (string, int)

Login renders the login page.

func (*MainController) LoginPost

func (controller *MainController) LoginPost(c web.C, r *http.Request) (string, int)

LoginPost is the form submit route. Logs user in or sets an appropriate message in session if login was not successful.

func (*MainController) Logout

func (controller *MainController) Logout(c web.C, r *http.Request) (string, int)

Logout the user.

func (*MainController) PasswordReset

func (controller *MainController) PasswordReset(c web.C, r *http.Request) (string, int)

PasswordReset renders the password reset page. This shows the form where the user enters their email address.

func (*MainController) PasswordResetPost

func (controller *MainController) PasswordResetPost(c web.C, r *http.Request) (string, int)

PasswordResetPost handles the posted password reset form. This submits the data entered into the email address form. If the email is recognized a password reset token is generated and the user will check their email for a link. The link will take them to the password update page with a token specified on the URL.

func (*MainController) PasswordUpdate

func (controller *MainController) PasswordUpdate(c web.C, r *http.Request) (string, int)

PasswordUpdate renders the password update page. When a user clicks the link containing a token in the password reset email, this handler will validate the token. When the token is valid, the user will be presented with forms to enter their new password. PasswordUpdatePost handles the submission of these forms, and calls PasswordUpdate again for page rendering.

func (*MainController) PasswordUpdatePost

func (controller *MainController) PasswordUpdatePost(c web.C, r *http.Request) (string, int)

PasswordUpdatePost handles updating passwords. The token in the URL is from the password reset email. The token is validated and the password is changed.

func (*MainController) RPCSync

func (controller *MainController) RPCSync(dbMap *gorp.DbMap) error

RPCSync checks to ensure that the wallets are synced on startup.

func (*MainController) Register

func (controller *MainController) Register(c web.C, r *http.Request) (string, int)

Register renders the register page.

func (*MainController) RegisterPost

func (controller *MainController) RegisterPost(c web.C, r *http.Request) (string, int)

RegisterPost form submit route. Registers new user or shows Registration route with appropriate messages set in session.

func (*MainController) Settings

func (controller *MainController) Settings(c web.C, r *http.Request) (string, int)

Settings renders the settings page.

func (*MainController) SettingsPost

func (controller *MainController) SettingsPost(c web.C, r *http.Request) (string, int)

SettingsPost handles changing the user's email address or password.

func (*MainController) StakepooldUpdateTickets

func (controller *MainController) StakepooldUpdateTickets(dbMap *gorp.DbMap) error

StakepooldUpdateTickets attempts to trigger all connected stakepoold instances to pull a data update of the specified kind.

func (*MainController) StakepooldUpdateUsers

func (controller *MainController) StakepooldUpdateUsers(dbMap *gorp.DbMap) error

StakepooldUpdateUsers attempts to trigger all connected stakepoold instances to pull a data update of the specified kind.

func (*MainController) Stats

func (controller *MainController) Stats(c web.C, r *http.Request) (string, int)

Stats renders the stats page.

func (*MainController) TicketAddressForUserID

func (controller *MainController) TicketAddressForUserID(uid int) (dcrutil.Address,
	error)

TicketAddressForUserID generates a unique ticket address per used ID for generating the 1-of-2 multisig.

func (*MainController) Tickets

func (controller *MainController) Tickets(c web.C, r *http.Request) (string, int)

Tickets renders the tickets page.

func (*MainController) Voting

func (controller *MainController) Voting(c web.C, r *http.Request) (string, int)

Voting renders the voting page.

func (*MainController) VotingPost

func (controller *MainController) VotingPost(c web.C, r *http.Request) (string, int)

VotingPost form submit route.

type TicketInfo

type TicketInfo struct {
	TicketHeight uint32
	Ticket       string
}

TicketInfo represents live or immature tickets that have yet to be spent by either a vote or revocation.

type TicketInfoHistoric

type TicketInfoHistoric struct {
	Ticket        string
	SpentBy       string
	SpentByHeight uint32
	TicketHeight  uint32
}

TicketInfoHistoric represents spent tickets, either voted or revoked.

type TicketInfoInvalid

type TicketInfoInvalid struct {
	Ticket string
}

TicketInfoInvalid represents tickets that were not added by the wallets for any reason (e.g. incorrect subsidy address or pool fees).

Jump to

Keyboard shortcuts

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