faucet

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package faucet outlines the faucet interface and its associated helper methods.

Package faucet outlines the faucet interface and its associated helper methods.

Package faucet outlines the faucet interface and its associated helper methods.

Package faucet outlines the faucet interface and its associated helper methods.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidClaimSize is an error definition describing a case in which a user attempts to claim more than is permitted.
	ErrInvalidClaimSize = errors.New("invalid claim; user cannot claim with provided amount")
)

Functions

This section is empty.

Types

type Faucet

type Faucet interface {
	WorkingDB() *accounts.DB // Get Accounts DB ref.

	AccountCanClaim(account *accounts.Account) bool       // Check account can claim summercash.
	AccountLastClaim(account *accounts.Account) time.Time // Get last time account claimed.

	AmountCanClaim(account *accounts.Account) *big.Float // Get the max amount an account can claim.

	Claim(account *accounts.Account, amount *big.Float) error // Claim an amount of summercash from the faucet.

	GetRuleset() *Ruleset // Get ruleset
}

Faucet defines all methods that should be associated with a faucet.

type Ruleset

type Ruleset interface {
	MaximumClaimInPeriod() *big.Float // Get max amount can claim in 24 hours.
	MinimumClaimInPeriod() *big.Float // Get min amount can claim in 24 hours.

	GetClaimPeriod() time.Duration // Get duration between possible claims

	DepositClaimCurve() float64 // Get amount to multiply possible claim by deposit by.

	BannedUsers() []*accounts.Account // Get banned users.
	BanUser(*accounts.Account)        // Ban user.
}

Ruleset defines all methods necessary to implement a ruleset.

type StandardFaucet

type StandardFaucet struct {
	Ruleset Ruleset // Faucet ruleset

	AccountsDatabase *accounts.DB // Accounts database
}

StandardFaucet outlines a standard faucet conforming to the standard ruleset.

func NewStandardFaucet

func NewStandardFaucet(ruleset Ruleset, accountsDB *accounts.DB) *StandardFaucet

NewStandardFaucet initializes a new standard faucet.

func (*StandardFaucet) AccountCanClaim

func (faucet *StandardFaucet) AccountCanClaim(account *accounts.Account) bool

AccountCanClaim checks if a given account can claim summercash.

func (*StandardFaucet) AccountLastClaim

func (faucet *StandardFaucet) AccountLastClaim(account *accounts.Account) time.Time

AccountLastClaim gets the time at which an account last claimed from the faucet.

func (*StandardFaucet) AmountCanClaim

func (faucet *StandardFaucet) AmountCanClaim(account *accounts.Account) *big.Float

AmountCanClaim gets the max amount an account can claim. If the account has already claimed in the last 24 hours, zero is returned.

func (*StandardFaucet) Claim

func (faucet *StandardFaucet) Claim(account *accounts.Account, amount *big.Float) error

Claim claims a given amount from the faucet.

func (*StandardFaucet) GetRuleset

func (faucet *StandardFaucet) GetRuleset() *Ruleset

GetRuleset gets the working ruleset.

func (*StandardFaucet) WorkingDB

func (faucet *StandardFaucet) WorkingDB() *accounts.DB

WorkingDB gets a reference to the faucet working database.

type StandardRuleset

type StandardRuleset struct {
	ClaimInPeriod *big.Float `json:"claim_24hr"` // Amount can claim in 24 hours.

	ClaimPeriod time.Duration `json:"claim_period"` // Claim period

	BannedUsersList []*accounts.Account `json:"banned_users"` // Banned users.
}

StandardRuleset outlines the standard ruleset implementation.

func NewStandardRuleset

func NewStandardRuleset(claimInPeriod *big.Float, claimPeriod time.Duration, bannedUsers []*accounts.Account) *StandardRuleset

NewStandardRuleset creates a new StandardRuleset instance with a given 24 hour claim amount and banned users list.

func (*StandardRuleset) BanUser

func (ruleset *StandardRuleset) BanUser(user *accounts.Account)

BanUser bans a given user.

func (*StandardRuleset) BannedUsers

func (ruleset *StandardRuleset) BannedUsers() []*accounts.Account

BannedUsers gets the list of banned users.

func (*StandardRuleset) DepositClaimCurve

func (ruleset *StandardRuleset) DepositClaimCurve() float64

DepositClaimCurve gets the claim curve.

func (*StandardRuleset) GetClaimPeriod

func (ruleset *StandardRuleset) GetClaimPeriod() time.Duration

GetClaimPeriod gets the claim duration.

func (*StandardRuleset) MaximumClaimInPeriod

func (ruleset *StandardRuleset) MaximumClaimInPeriod() *big.Float

MaximumClaimInPeriod gets the max amount one user can claim in 24 hours.

func (*StandardRuleset) MinimumClaimInPeriod

func (ruleset *StandardRuleset) MinimumClaimInPeriod() *big.Float

MinimumClaimInPeriod gets the min amount on user can claim in 24 hours.

Jump to

Keyboard shortcuts

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