Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

bubblerumble source realm

Package bubblerumble is a last-bidder-wins game in GNOT.

Overview

Package bubblerumble is a last-bidder-wins game in GNOT.

A pool has a pot and a clock. Every bid goes into the pot and resets the clock; the Nth bid costs BasePrice·√N. When the clock runs out, the last bidder takes the whole pot. Anyone can open a pool, and the coins sent with CreatePool seed its pot.

Paying more than the price buys a shorter clock: k× the price gives that bid a clock of window/k, never below a tenth of the window. The whole amount goes into the pot, and the next bid runs the full window again.

Constants 1

Functions 8

func Bid

crossing Action
1func Bid(cur realm, id int64)
source

Bid pays at least the current price into a pool's pot and resets its clock; paying k× the price makes this bid's clock window/k (see ClockFor).

func Cancel

crossing Action
1func Cancel(cur realm, id int64)
source

Cancel lets the creator take the seed back from a pool nobody has bid on.

func Claim

crossing Action
1func Claim(cur realm, id int64)
source

Claim sends a finished pool's pot to its winner. Anyone may call it.

func ClockFor

Action
1func ClockFor(window, price, sent int64) int64
source

ClockFor is the clock a bid buys by paying sent against a price: the window divided by the multiple paid, never below window/MaxBoost.

func CreatePool

crossing Action
1func CreatePool(cur realm, name string, window int64, basePrice int64) int64
source

CreatePool opens a pool. Any ugnot sent with the call seeds its pot. Returns the new pool's id.

func GNOT

Action
1func GNOT(ugnot int64) string
source

GNOT formats ugnot as GNOT with the trailing zeros trimmed.

func Price

Action
1func Price(base, n int64) int64
source

Price of the next bid in a pool with the given base price and n bids so far. Sublinear in n: bid 1 costs base, bid 4 costs 2·base, bid 100 costs 10·base.

func Render

1func Render(path string) string
source

Render serves gnoweb ("" and "<id>") and the web page ("json" and "json/<id>").

Types 2

type Entry

struct
1type Entry struct {
2	N      int64
3	Bidder address
4	Price  int64 // what was paid; at least the price at the time
5	Clock  int64 // seconds this bid had to stand
6	Pot    int64 // pot right after this bid
7	At     time.Time
8}
source

type Pool

struct
 1type Pool struct {
 2	ID         int64
 3	Name       string
 4	Creator    address
 5	Window     int64 // seconds the last bid must stand to win
 6	BasePrice  int64 // ugnot; the Nth bid costs BasePrice·√N
 7	Seed       int64
 8	Pot        int64
 9	Bids       int64
10	LastBidder address
11	LastBidAt  time.Time
12	Clock      int64 // seconds the current top bid has to stand: Window, or less if it paid for it
13	CreatedAt  time.Time
14	Paid       bool // the pot went to the winner, or the seed back to the creator
15	Cancelled  bool
16	History    []Entry
17}
source

Methods on Pool

func Deadline

method on Pool
1func (p *Pool) Deadline() time.Time
source

Deadline is when the pool closes if nobody else bids. Meaningless before the first bid.

func NextPrice

method on Pool
1func (p *Pool) NextPrice() int64
source

NextPrice is what the next bid costs.

func Over

method on Pool
1func (p *Pool) Over() bool
source

Over reports whether the clock has run out, which is the moment a pool has a winner.

Imports 7

  • chain stdlib
  • chain/banker stdlib
  • chain/runtime/unsafe stdlib
  • math stdlib
  • strconv stdlib
  • strings stdlib
  • time stdlib

Source Files 2