Documentation
¶
Index ¶
- Constants
- Variables
- func BetIDString(id *poolpb.BetId) string
- func GetUserSummary(ctx context.Context, pools Store, codeData codedata.Provider, ...) (*poolpb.UserPoolSummary, error)
- func NewStaleEventDetector() event.StaleEventDetector[*eventpb.Event]
- func PoolIDString(id *poolpb.PoolId) string
- func ToBetID(keyPair model.KeyPair) *poolpb.BetId
- func ToPoolID(keyPair model.KeyPair) *poolpb.PoolId
- func VerifyBetSignature(log *zap.Logger, poolID *poolpb.PoolId, signedBet *poolpb.SignedBetMetadata, ...) bool
- func VerifyPoolSignature(log *zap.Logger, signedPool *poolpb.SignedPoolMetadata, ...) bool
- type Bet
- type IntentHandler
- func (h *IntentHandler) OnSuccessfulBetPayment(ctx context.Context, intentRecord *codeintent.Record) error
- func (h *IntentHandler) ValidateBetPayment(ctx context.Context, intentRecord *codeintent.Record) error
- func (h *IntentHandler) ValidateDistribution(ctx context.Context, intentRecord *codeintent.Record, ...) error
- type Member
- type Pool
- type Resolution
- type Server
- func (s *Server) ClosePool(ctx context.Context, req *poolpb.ClosePoolRequest) (*poolpb.ClosePoolResponse, error)
- func (s *Server) CreatePool(ctx context.Context, req *poolpb.CreatePoolRequest) (*poolpb.CreatePoolResponse, error)
- func (s *Server) GetPagedPools(ctx context.Context, req *poolpb.GetPagedPoolsRequest) (*poolpb.GetPagedPoolsResponse, error)
- func (s *Server) GetPool(ctx context.Context, req *poolpb.GetPoolRequest) (*poolpb.GetPoolResponse, error)
- func (s *Server) MakeBet(ctx context.Context, req *poolpb.MakeBetRequest) (*poolpb.MakeBetResponse, error)
- func (s *Server) ResolvePool(ctx context.Context, req *poolpb.ResolvePoolRequest) (*poolpb.ResolvePoolResponse, error)
- type StaleEventDetector
- type Store
Constants ¶
View Source
const (
MaxParticipants = 1000
)
Variables ¶
View Source
var ( ErrPoolNotFound = errors.New("pool not found") ErrPoolIDExists = errors.New("pool id already exists") ErrPoolFundingDestinationExists = errors.New("pool funding address already exists") ErrPoolOpen = errors.New("pool is open") ErrPoolResolved = errors.New("pool is already resolved") ErrBetNotFound = errors.New("bet not found") ErrBetExists = errors.New("bet already exists") ErrMaxBetCountExceeded = errors.New("max bet count exceeded") ErrMemberNotFound = errors.New("pool member not found") )
Functions ¶
func BetIDString ¶
func GetUserSummary ¶ added in v1.8.17
func NewStaleEventDetector ¶ added in v1.10.5
func NewStaleEventDetector() event.StaleEventDetector[*eventpb.Event]
func PoolIDString ¶
func VerifyBetSignature ¶
func VerifyPoolSignature ¶
Types ¶
type Bet ¶
type Bet struct {
PoolID *poolpb.PoolId
ID *poolpb.BetId
UserID *commonpb.UserId
SelectedOutcome bool
PayoutDestination *commonpb.PublicKey
Ts time.Time
IsIntentSubmitted bool // Use IsPaid utility before trusting this value
Signature *commonpb.Signature
}
func GetBetSummary ¶ added in v1.8.17
func GetBetSummary(ctx context.Context, pools Store, codeData codedata.Provider, pool *Pool) (*poolpb.BetSummary, []*Bet, error)
todo: optimize when we don't require the entire bet list
func ToBetModel ¶
func (*Bet) ToProto ¶
func (b *Bet) ToProto() *poolpb.BetMetadata
type IntentHandler ¶ added in v1.10.5
type IntentHandler struct {
// contains filtered or unexported fields
}
todo: add tests
func NewIntentHandler ¶ added in v1.10.5
func (*IntentHandler) OnSuccessfulBetPayment ¶ added in v1.10.5
func (h *IntentHandler) OnSuccessfulBetPayment(ctx context.Context, intentRecord *codeintent.Record) error
func (*IntentHandler) ValidateBetPayment ¶ added in v1.10.5
func (h *IntentHandler) ValidateBetPayment(ctx context.Context, intentRecord *codeintent.Record) error
func (*IntentHandler) ValidateDistribution ¶ added in v1.10.5
func (h *IntentHandler) ValidateDistribution(ctx context.Context, intentRecord *codeintent.Record, actions []*codetransactionpb.Action) error
type Member ¶ added in v1.8.1
func CloneMembers ¶ added in v1.8.1
type Pool ¶
type Pool struct {
ID *poolpb.PoolId
CreatorID *commonpb.UserId
Name string
BuyInCurrency string
BuyInAmount float64
FundingDestination *commonpb.PublicKey
IsOpen bool
Resolution Resolution
CreatedAt time.Time
ClosedAt *time.Time
Signature *commonpb.Signature
}
func ClonePools ¶
func ToPoolModel ¶
func ToPoolModel(proto *poolpb.SignedPoolMetadata, signature *commonpb.Signature) *Pool
func (*Pool) HasResolution ¶ added in v1.8.11
func (*Pool) ToProto ¶
func (p *Pool) ToProto() *poolpb.PoolMetadata
type Resolution ¶ added in v1.8.4
type Resolution int
const ( ResolutionUnknown Resolution = iota ResolutionRefunded ResolutionYes ResolutionNo )
func ToResolution ¶ added in v1.8.4
func ToResolution(proto *poolpb.Resolution) Resolution
func (Resolution) String ¶ added in v1.8.4
func (r Resolution) String() string
func (*Resolution) ToProto ¶ added in v1.8.4
func (r *Resolution) ToProto() *poolpb.Resolution
type Server ¶
type Server struct {
poolpb.UnimplementedPoolServer
// contains filtered or unexported fields
}
func (*Server) ClosePool ¶ added in v1.8.3
func (s *Server) ClosePool(ctx context.Context, req *poolpb.ClosePoolRequest) (*poolpb.ClosePoolResponse, error)
func (*Server) CreatePool ¶
func (s *Server) CreatePool(ctx context.Context, req *poolpb.CreatePoolRequest) (*poolpb.CreatePoolResponse, error)
todo: Add buy in amount validation (min/max)
func (*Server) GetPagedPools ¶ added in v1.8.1
func (s *Server) GetPagedPools(ctx context.Context, req *poolpb.GetPagedPoolsRequest) (*poolpb.GetPagedPoolsResponse, error)
func (*Server) GetPool ¶
func (s *Server) GetPool(ctx context.Context, req *poolpb.GetPoolRequest) (*poolpb.GetPoolResponse, error)
func (*Server) MakeBet ¶
func (s *Server) MakeBet(ctx context.Context, req *poolpb.MakeBetRequest) (*poolpb.MakeBetResponse, error)
func (*Server) ResolvePool ¶
func (s *Server) ResolvePool(ctx context.Context, req *poolpb.ResolvePoolRequest) (*poolpb.ResolvePoolResponse, error)
type StaleEventDetector ¶ added in v1.10.5
type StaleEventDetector struct {
// contains filtered or unexported fields
}
todo: add tests
func (*StaleEventDetector) ShouldDrop ¶ added in v1.10.5
func (d *StaleEventDetector) ShouldDrop(e *eventpb.Event) bool
type Store ¶
type Store interface {
// Create pool creates a new betting pool
CreatePool(ctx context.Context, pool *Pool) error
// ClosePool closes a pool
ClosePool(ctx context.Context, poolID *poolpb.PoolId, closedAt time.Time, newSignature *commonpb.Signature) error
// ResolvePool resolves a pool with an outcome
ResolvePool(ctx context.Context, poolID *poolpb.PoolId, resolution Resolution, newSignature *commonpb.Signature) error
// GetPoolByID gets a betting pool by ID
GetPoolByID(ctx context.Context, poolID *poolpb.PoolId) (*Pool, error)
// GetPoolByFundingDestination gets a betting pool by the funding destination
GetPoolByFundingDestination(ctx context.Context, fundingDestination *commonpb.PublicKey) (*Pool, error)
// CreateBet creates a new bet
CreateBet(ctx context.Context, bet *Bet) error
// UpdateBetOutcome updates an existing bet's outcome
UpdateBetOutcome(ctx context.Context, betId *poolpb.BetId, newOutcome bool, newSignature *commonpb.Signature, newTs time.Time) error
// MarkBetAsPaid marks a bet as paid
MarkBetAsPaid(ctx context.Context, betId *poolpb.BetId) error
// GetBetByID gets a bet by its ID
GetBetByID(ctx context.Context, betID *poolpb.BetId) (*Bet, error)
// GetBetByUser gets a bet for a pool made by a user
GetBetByUser(ctx context.Context, poolID *poolpb.PoolId, userID *commonpb.UserId) (*Bet, error)
// GetBetsByPool gets all bets for a given pool
GetBetsByPool(ctx context.Context, poolID *poolpb.PoolId) ([]*Bet, error)
// GetMember gets the pool memberships for the provided pool and user
GetMember(ctx context.Context, poolID *poolpb.PoolId, userID *commonpb.UserId) (*Member, error)
// GetPagedMembers gets the set of pool memberships for the provided user
// over a paged API
GetPagedMembers(ctx context.Context, userID *commonpb.UserId, options ...database.QueryOption) ([]*Member, error)
}
Click to show internal directories.
Click to hide internal directories.