belt

package module
v0.0.0-...-0685199 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetFS

func AssetFS() *assetfs.AssetFS

func Context

func Context(h http.Handler) http.Handler

func Edit

func Edit(w http.ResponseWriter, r *http.Request)

func GetAddr

func GetAddr(w http.ResponseWriter, r *http.Request)

GetAddr requires app context for registering on txfilter

func Index

func Index(w http.ResponseWriter, r *http.Request)

func Migrate

func Migrate(db *gorm.DB) error

func PlaceVote

func PlaceVote(w http.ResponseWriter, r *http.Request)

func SaveEdit

func SaveEdit(w http.ResponseWriter, r *http.Request)

func View

func View(w http.ResponseWriter, r *http.Request)

Types

type App

type App struct {
	Upgrader websocket.Upgrader

	Token string
	// contains filtered or unexported fields
}

func NewApp

func NewApp(db *gorm.DB, token string) *App

func (*App) OnNewChatMessage

func (app *App) OnNewChatMessage(channel string, user twitch.User, message twitch.Message)

func (*App) Payout

func (app *App) Payout(w http.ResponseWriter, r *http.Request)

func (*App) Ping

func (app *App) Ping()

TODO: remove

func (*App) RPCLoad

func (app *App) RPCLoad(addrs []fakutil.Address) error

func (*App) SetBelt

func (app *App) SetBelt(w http.ResponseWriter, r *http.Request)

func (*App) Socket

func (app *App) Socket(w http.ResponseWriter, r *http.Request)

func (*App) StartChatMonitor

func (app *App) StartChatMonitor(channel string) error

func (*App) StartRPC

func (app *App) StartRPC(cfg *rpcclient.ConnConfig, params *chaincfg.Params) (err error)

type Belt

type Belt struct {
	gorm.Model

	Title   string    `json:"title" gorm:"unique_index;not null"`
	Message string    `json:"message"`
	EndTime time.Time `json:"endtime"`

	Options []Option `json:"options"`
}

func (Belt) Ended

func (b Belt) Ended() bool

func (Belt) Info

func (b Belt) Info() template.HTML

func (Belt) ShortID

func (b Belt) ShortID() string

func (Belt) TxIn

func (b Belt) TxIn() ([]string, []*wire.TxIn)

type BeltCtx

type BeltCtx struct {
	*Belt
	// contains filtered or unexported fields
}

func (*BeltCtx) Save

func (ctx *BeltCtx) Save() error

func (*BeltCtx) SaveWithOptions

func (ctx *BeltCtx) SaveWithOptions(opts []Option) error

type BeltHolder

type BeltHolder uint
const (
	Brian BeltHolder = 1 << iota
	Jury
	Bryce
	Bonnie
)

func Check

func Check(msg string) (hold BeltHolder)

func Win

func Win(h [4]int) ([]BeltHolder, int)

func (BeltHolder) Split

func (h BeltHolder) Split() (ret [4]int)

func (BeltHolder) Split2

func (h BeltHolder) Split2() (ret []BeltHolder)

func (BeltHolder) String

func (h BeltHolder) String() string

type Bet

type Bet struct {
	ID        uint      `json:"-" gorm:"primary_key"`
	CreatedAt time.Time `json:"-"`
	OptionID  uint      `json:"-"`

	WIFKey    string `json:"-"`
	WatchAddr string `json:"watchaddr" gorm:"size:35;unique_index;not null"`
	PayAddr   string `json:"payaddr" gorm:"size:35"`

	Transactions []BetTx `json:"txs"`
}

func (Bet) Value

func (b Bet) Value(minConf int) FAK

type BetTx

type BetTx struct {
	ID        uint      `json:"-" gorm:"primary_key"`
	CreatedAt time.Time `json:"-"`
	BetID     uint      `json:"-"`

	Hash  string `json:"hash" gorm:"size:64;unique_index;not null"`
	Index uint32 `json:"index" gorm:"not null"`
	Value FAK    `json:"value" gorm:"not null"`

	Confirmations int `json:"confirmations" gorm:"default:0;not null"`
}

func (BetTx) WireInput

func (tx BetTx) WireInput() *wire.TxIn

type ChatMsg

type ChatMsg struct {
	twitch.User
	twitch.Message
	Belt BeltHolder
}

type FAK

type FAK uint64

func (FAK) Int

func (f FAK) Int() uint64

func (FAK) String

func (f FAK) String() string

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func NewHub

func NewHub() *Hub

func (*Hub) BeltHolder

func (h *Hub) BeltHolder() int64

func (*Hub) Ping

func (h *Hub) Ping()

func (*Hub) SetHolder

func (h *Hub) SetHolder(id int64)

func (*Hub) Subscribe

func (h *Hub) Subscribe(ch chan []byte) (int, error)

func (*Hub) Unsubscribe

func (h *Hub) Unsubscribe(id int)

type LogLog

type LogLog struct {
	// contains filtered or unexported fields
}

type Option

type Option struct {
	ID     uint `gorm:"primary_key"`
	BeltID uint `json:"-" gorm:"unique_index:unique_belt_option"`

	Name  string `json:"name" gorm:"unique_index:unique_belt_option;not null"`
	Image string `json:"image"`

	Votes uint `json:"votes"`

	Bets []Bet
}

func (Option) Value

func (o Option) Value(minConf int) FAK

func (Option) WireOutput

func (o Option) WireOutput(amount FAK) []*wire.TxOut

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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