oracle: add oracle client.#11
Conversation
This implements an oracle client that subscribes to mesh topics to receive real-time asset prices and network fee rates. Associated tests have been added.
8a582dc to
350de28
Compare
| t.Fatal(err) | ||
| } | ||
|
|
||
| mc, err := meshclient.NewClient(&meshclient.Config{ |
There was a problem hiding this comment.
./harness_test.go:83:13: undefined: meshclient
|
|
||
| go func() { | ||
| defer wg.Done() | ||
| if err := mc.Run(ctx, nil); err != nil && err != context.Canceled { |
There was a problem hiding this comment.
context.Canceled will never be returned from Run
| if err := c.mc.WaitForConnection(ctx); err != nil { | ||
| return err | ||
| } |
There was a problem hiding this comment.
I don't think this is actually helpful. We may have initially established a connection (in which case this will return a nil error), but then the connection may be lost, causing the subscribe calls to fail. I think we should not return an error in Subscribe if there is no active mesh connection. It should succeed and record the topic in the topic registry. Then when a connection is established, the client will automatically subscribe to the topics it needs.
| c.mtx.Unlock() | ||
| } | ||
|
|
||
| priceTopic := protocols.PriceTopicPrefix + asset |
There was a problem hiding this comment.
Let's add a function in the protocols package that takes the asset string and returns the full string. Let's not do the concatenation here.
| return | ||
| } | ||
| m.primaryConn.Store(&meshConnHolder{mc: mc}) | ||
| if m.connectedCh != nil { |
There was a problem hiding this comment.
This will never be nil, but I don't think we need any of this anyways.
There was a problem hiding this comment.
I may be missing some outside conversation, but what do you mean by "but I don't think we need any of this anyways"?
| whitelistPath := fmt.Sprintf("%s/%s", curUser.HomeDir, ".tatanka-test/whitelist.json") | ||
| whitelist := struct { | ||
| Peers []struct { | ||
| ID string `json:"id"` | ||
| Address string `json:"address"` | ||
| } `json:"peers"` | ||
| }{} |
There was a problem hiding this comment.
This will need to be updated after I merge the whitelist updates.
|
|
||
| func (c *Client) subscribe(ctx context.Context) error { | ||
| for _, asset := range c.cfg.Assets { | ||
| asset := asset |
There was a problem hiding this comment.
This is unnecessary after go 1.22.
|
Why do we need a separate client for the oracle feed? Can't we just have privileged endpoints for regular clients? |
It's just wrapper around the client that Bison Wallet can import. |
Are you planning other types of clients? |
|
The client has been updated in #14 to handle oracle subscriptions and update processing. This is no longer needed, closing. |
This implements an oracle client that subscribes to mesh topics to receive real-time asset prices and network fee rates. Associated tests have been added.