Skip to content

oracle: add oracle client.#11

Closed
dnldd wants to merge 1 commit intobisoncraft:masterfrom
dnldd:add-oracle-client
Closed

oracle: add oracle client.#11
dnldd wants to merge 1 commit intobisoncraft:masterfrom
dnldd:add-oracle-client

Conversation

@dnldd
Copy link
Copy Markdown
Contributor

@dnldd dnldd commented Feb 22, 2026

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.

Comment thread oracle/client/client.go Outdated
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.
@dnldd dnldd force-pushed the add-oracle-client branch from 8a582dc to 350de28 Compare February 24, 2026 23:43
t.Fatal(err)
}

mc, err := meshclient.NewClient(&meshclient.Config{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./harness_test.go:83:13: undefined: meshclient


go func() {
defer wg.Done()
if err := mc.Run(ctx, nil); err != nil && err != context.Canceled {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context.Canceled will never be returned from Run

Comment thread oracle/client/client.go
Comment on lines +87 to +89
if err := c.mc.WaitForConnection(ctx); err != nil {
return err
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread oracle/client/client.go
c.mtx.Unlock()
}

priceTopic := protocols.PriceTopicPrefix + asset
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never be nil, but I don't think we need any of this anyways.

Copy link
Copy Markdown
Contributor

@buck54321 buck54321 Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing some outside conversation, but what do you mean by "but I don't think we need any of this anyways"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +28 to +34
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"`
}{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be updated after I merge the whitelist updates.

Comment thread oracle/client/client.go

func (c *Client) subscribe(ctx context.Context) error {
for _, asset := range c.cfg.Assets {
asset := asset
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary after go 1.22.

@buck54321
Copy link
Copy Markdown
Contributor

Why do we need a separate client for the oracle feed? Can't we just have privileged endpoints for regular clients?

@martonp
Copy link
Copy Markdown
Contributor

martonp commented Feb 25, 2026

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.

@buck54321
Copy link
Copy Markdown
Contributor

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?

@dnldd
Copy link
Copy Markdown
Contributor Author

dnldd commented Feb 26, 2026

The client has been updated in #14 to handle oracle subscriptions and update processing. This is no longer needed, closing.

@dnldd dnldd closed this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants