aboutsummaryrefslogtreecommitdiff
path: root/client/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/client.go')
-rw-r--r--client/client.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/client/client.go b/client/client.go
new file mode 100644
index 0000000..19f0d35
--- /dev/null
+++ b/client/client.go
@@ -0,0 +1,54 @@
+package client
+
+import (
+ "fmt"
+ "log"
+ "os"
+
+ "kesim.org/seal"
+)
+
+type Auction struct {
+ description *seal.Description
+
+ bid *bid
+
+ 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 {
+ bid, e := newBid(price, a.description.BitLength)
+ if e != nil {
+ return e
+ }
+
+ a.debug("created bid: %#v\n", bid)
+
+ a.bid = bid
+ return nil
+}