aboutsummaryrefslogtreecommitdiff
path: root/bidder/auction.go
diff options
context:
space:
mode:
Diffstat (limited to 'bidder/auction.go')
-rw-r--r--bidder/auction.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/bidder/auction.go b/bidder/auction.go
new file mode 100644
index 0000000..7991504
--- /dev/null
+++ b/bidder/auction.go
@@ -0,0 +1,60 @@
+package bidder
+
+import (
+ "fmt"
+ "log"
+ "os"
+
+ "kesim.org/seal"
+)
+
+type Auction struct {
+ description *seal.Description
+
+ bidder seal.Bidder
+
+ log func(string, ...any)
+ verbose func(string, ...any)
+ debug func(string, ...any)
+}
+
+func nullf(string, ...any) {}
+
+func NewAuction(description *seal.Description, options ...Option) (auction *Auction, e error) {
+ if description.BitLength > 63 {
+ return nil, fmt.Errorf("Invalid BitLength in description: %d", description.BitLength)
+ }
+
+ logger := log.New(os.Stdout, "[seal::client] ", log.LstdFlags)
+
+ auction = &Auction{
+ description: description,
+ log: logger.Printf,
+ verbose: nullf,
+ debug: nullf,
+ }
+
+ for _, opt := range options {
+ opt(auction)
+ }
+
+ return auction, nil
+}
+
+func (a *Auction) Join(price uint64) error {
+ bidder, e := newBid(price, a.description.BitLength)
+ if e != nil {
+ return e
+ }
+
+ a.debug("created bid: %#v\n", bidder.(*bid))
+
+ a.bidder = bidder
+ return nil
+}
+
+// Received is called by the consumer whenever a message came in for the auction via the dashboard
+// or other means of communication.
+func (a *Auction) Received(msg []byte) error {
+ return fmt.Errorf("Auction.Received not implemented")
+} \ No newline at end of file