aboutsummaryrefslogtreecommitdiff
path: root/client/client.go
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@codeblau.de>2024-04-05 18:06:35 +0200
committerÖzgür Kesim <oec@codeblau.de>2024-04-05 18:06:35 +0200
commit5733f293044bfe0d3210e7c4688172d53d54a7e0 (patch)
treeb8f3da57d83410a9b3f7efe0b856729ca48d804b /client/client.go
parente735cff1d63145b89c4c48b9d73f037d3a4305f4 (diff)
client: started work on API for client, wip
- auction defines description of an auction - client creates auction object, given a description - commitment/* merged into client
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
+}