Documentation ¶
Index ¶
- func ComputeReward(totalAmount payment.Amount, numUsers int) payment.Amount
- type ActivityChallenge
- type ActivityChallengeType
- type ChallengeCheckFunction
- type Handler
- func (r *Handler) ConnectedSpectators() []Spectator
- func (r *Handler) CountConnectedSpectatorsOnRemoteAddress(remoteAddress string) int
- func (r *Handler) EstimateEligibleSpectators() (int, bool)
- func (r *Handler) GetSpectator(address string) (Spectator, bool)
- func (r *Handler) GetSpectatorActivityStatus(address string) proto.UserStatus
- func (r *Handler) MarkAddressAsActiveEvenIfChallenged(ctx context.Context, address string) error
- func (r *Handler) MarkAddressAsActiveIfNotChallenged(ctx context.Context, address string) error
- func (r *Handler) MarkAddressAsNotLegitimate(ctx context.Context, address string)
- func (r *Handler) RegisterSpectator(ctx context.Context, user auth.User) (Spectator, error)
- func (r *Handler) RemoteAddressesForRewardAddress(ctx context.Context, rewardAddress string) map[string]struct{}
- func (r *Handler) ResetAddressLegitimacyStatus(ctx context.Context, address string) error
- func (r *Handler) RewardsDistributed() event.Event[RewardsDistributedEventArgs]
- func (r *Handler) SolveActivityChallenge(ctxCtx context.Context, challenge string, checkResponses []string, ...) (skippedClientIntegrityChecks bool, err error)
- func (r *Handler) SpectatorConnected() event.Event[Spectator]
- func (r *Handler) SpectatorDisconnected() event.Event[Spectator]
- func (r *Handler) SpectatorHasActivityChallenge(address string, challengeType ActivityChallengeType) bool
- func (r *Handler) UnregisterSpectator(ctx context.Context, sInterface Spectator) error
- func (r *Handler) Worker(ctx context.Context) error
- type RewardsDistributedEventArgs
- type Spectator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActivityChallenge ¶
type ActivityChallenge struct { ChallengedAt time.Time ID string Types []ActivityChallengeType Tolerance time.Duration }
func (*ActivityChallenge) SerializeForAPI ¶
func (a *ActivityChallenge) SerializeForAPI() *proto.ActivityChallenge
type ActivityChallengeType ¶
type ActivityChallengeType string
ActivityChallengeType is a type of activity challenge
var ( // ActivityChallengeTypeButton is a button activity challenge ActivityChallengeTypeButton ActivityChallengeType = "button" // ActivityChallengeTypeSegcha is a segcha activity challenge ActivityChallengeTypeSegcha ActivityChallengeType = "segcha" // ActivityChallengeTypeTurnstile is a Cloudflare Turnstile activity challenge ActivityChallengeTypeTurnstile ActivityChallengeType = "turnstile" // ActivityChallengeTypeModerating is a moderation activity challenge ActivityChallengeTypeModerating ActivityChallengeType = "moderating" )
type ChallengeCheckFunction ¶
ChallengeCheckFunction checks activity challenge response correctness
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles reward distribution among spectators
func NewHandler ¶
func NewHandler(log *log.Logger, statsClient *statsd.Client, mediaQueue *mediaqueue.MediaQueue, ipReputationChecker *ipreputation.Checker, withdrawalHandler *withdrawalhandler.Handler, wallet *wallet.Wallet, collectorAccountQueue chan func(*wallet.Account, *rpc.Client, *rpc.Client), skipManager *skipmanager.Manager, chatManager *chatmanager.Manager, pointsManager *pointsmanager.Manager, notificationManager *notificationmanager.Manager, paymentAccountPool *payment.PaymentAccountPool, moderationStore moderation.Store, staffActivityManager *staffactivitymanager.Manager, challengeCheckers map[ActivityChallengeType]ChallengeCheckFunction, versionHashGetter func() string) (*Handler, error)
NewHandler creates a new RewardsHandler
func (*Handler) ConnectedSpectators ¶
func (*Handler) CountConnectedSpectatorsOnRemoteAddress ¶
func (*Handler) EstimateEligibleSpectators ¶
func (*Handler) GetSpectatorActivityStatus ¶
func (r *Handler) GetSpectatorActivityStatus(address string) proto.UserStatus
func (*Handler) MarkAddressAsActiveEvenIfChallenged ¶
func (*Handler) MarkAddressAsActiveIfNotChallenged ¶
func (*Handler) MarkAddressAsNotLegitimate ¶
func (*Handler) RegisterSpectator ¶
func (*Handler) RemoteAddressesForRewardAddress ¶
func (*Handler) ResetAddressLegitimacyStatus ¶
func (*Handler) RewardsDistributed ¶
func (r *Handler) RewardsDistributed() event.Event[RewardsDistributedEventArgs]
RewardsDistributed is the event that is fired when rewards are distributed for a queue entry
func (*Handler) SolveActivityChallenge ¶
func (*Handler) SpectatorConnected ¶
SpectatorConnected is the event that is fired when a spectator establishes their first connection
func (*Handler) SpectatorDisconnected ¶
SpectatorDisconnected is the event that is fired when a spectator disconnects their last remaining connection
func (*Handler) SpectatorHasActivityChallenge ¶
func (r *Handler) SpectatorHasActivityChallenge(address string, challengeType ActivityChallengeType) bool
func (*Handler) UnregisterSpectator ¶
type RewardsDistributedEventArgs ¶
type RewardsDistributedEventArgs struct { RewardBudget payment.Amount EligibleSpectators []string RequesterReward payment.Amount Media media.QueueEntry }
RewardsDistributedEventArgs are the arguments to the event that is fired when rewards are distributed for a queue entry
type Spectator ¶
type Spectator interface { User() auth.User OnActivityChallenge() event.Event[*ActivityChallenge] CurrentActivityChallenge() *ActivityChallenge Legitimate() (bool, time.Time) CurrentRemoteAddress() string GoodRemoteAddressReputation(context.Context, *Handler) (bool, bool) CountOtherConnectedSpectatorsOnSameRemoteAddress(*Handler) int WatchingSince() time.Time StoppedWatching() (bool, time.Time) ConnectionCount() int }
Click to show internal directories.
Click to hide internal directories.