Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: Refactor wallet.NetworkBackend. #2320

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

matheusd
Copy link
Member

This unifies the wallet's Peer and NetworkBackend interfaces into a single interface, given the SPV peer syncer now fulfills both roles.

In order to complete the refactor, the following changes are made:

  • The funcs that were in Peer are moved to NetworkBackend.
  • The missing funcs are added to chain.Syncer, forwading the calls to the dcrd client connection.
  • chain.Syncer assigns itself as NetworkBackend to the wallet, instead of assigning the client connection.
  • deployments package is modified to take a more limited interface (Querier) instead of the syncer var directly, to avoid circular pkg dependencies.
  • The live ticket querier (in tickets.go) is modified to take a more limited interface instead of the syncer var directly, to avoid circular pkg dependencies.
  • Call sites that type selected on *dcrd.RPC are modified to type select on *chain.Syncer.
  • A Synced() function is added to the NetworkBackend interface so that the JSON-RPC server can more accurately query for synced status from the underlying syncer.

In the future, the dependency on concrete type checking could be further reduced on other call sites by using the same technique that was employed in this commit for the deployments package.

Close #2317.

chain/sync.go Show resolved Hide resolved
@matheusd matheusd force-pushed the rpc-network-backend branch from 2956858 to a918500 Compare January 22, 2024 17:50
Copy link
Member

@jrick jrick left a comment

Choose a reason for hiding this comment

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

please squash

@matheusd matheusd force-pushed the rpc-network-backend branch from a918500 to 95f7cfe Compare January 30, 2024 10:04
@jrick
Copy link
Member

jrick commented Jan 30, 2024

@matheusd you still have the commit message from the second commit in the squashed commit :p

This unifies the wallet's Peer and NetworkBackend interfaces into a
single interface, given the SPV peer syncer now fulfills both roles.

In order to complete the refactor, the following changes are made:

- The funcs that were in Peer are moved to NetworkBackend.
- The missing funcs are added to chain.Syncer, forwading the calls to
  the dcrd client connection.
- chain.Syncer assigns itself as NetworkBackend to the wallet, instead
  of assigning the client connection.
- deployments package is modified to take a more limited interface
  (Querier) instead of the syncer var directly, to avoid circular pkg
  dependencies.
- The live ticket querier (in tickets.go) is modified to take a more
  limited interface instead of the syncer var directly, to avoid
  circular pkg dependencies.
- Call sites that type selected on *dcrd.RPC are modified to type select
  on *chain.Syncer.
- A Synced() function is added to the NetworkBackend interface so that
  the JSON-RPC server can more accurately query for synced status from
  the underlying syncer.

In the future, the dependency on concrete type checking could be further
reduced on other call sites by using the same technique that was
employed in this commit for the deployments package.
@matheusd matheusd force-pushed the rpc-network-backend branch from 95f7cfe to 6cde2cc Compare January 31, 2024 10:12
@matheusd
Copy link
Member Author

grrrr, sorry for that. Updated.

@jrick jrick merged commit 6cde2cc into decred:master Jan 31, 2024
2 checks passed
@matheusd matheusd deleted the rpc-network-backend branch January 31, 2024 14:50
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.

syncstatus.Synced does not reflect discovery progress in RPC mode
2 participants