-
Notifications
You must be signed in to change notification settings - Fork 4
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
First implementation of services #2
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
altafan
requested changes
Feb 22, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All repositories' methods should expect a first arg context.Context
.
altafan
reviewed
Feb 22, 2022
altafan
reviewed
Feb 24, 2022
altafan
reviewed
Feb 24, 2022
altafan
reviewed
Mar 2, 2022
altafan
approved these changes
Mar 2, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR proposes the first implementation of
NodeService
andScannerService
.The terminology of services and methods can differ from the ones discussed in #1. I finally splited the code into two services:
NodeService
which basically aims to be a full elements node syncing block headers and block compact filters.ScannerService
which is the former "UtxoService", responsible of resolving "ScanRequest".Elements Full node (NodeService)
FilterRepository
andBlockHeaderRepository
to fill headers and filters databases.inv
messages but uses BIP0130 to sync headers (low bandwidth nodes)Scanner service (BIP158)
FilterRepository
andBlockHeaderRepository
interfaces.Watch
method to sendScanRequest
, then the scanner will return aSpendReport
as soon as it finds theWatchItem
using filters.requestWorker
function).How to quick test
This PR provides a simple CLI using to test this POC full node + filter scanner, u can run the following:
(or build the binary)
The
start
command lets u run a full node which will sync with your nigiri instance. It also silently run aScannerService
and sends a ScanRequest on the following address:As soon as you faucet this address, the scanner will log a report with txid.
PS: Note that this "WatchItem" is an
AddressWatchItem
, we can also watch for outpoint to be spent withOutpointWatchItem
or whatever implementingWatchItem
interface.About WASM
ScannerService
, it should be easy to reimplement it for browser using Javascript. This good article from Trezor's blog demonstrates it.NodeService
, the hard part is the communication with peers. That's whynode
pkg never handles directly TCP streams, thepeer
pkg is here to abstract this. The idea could be to rewrite a browser-compatiblePeer
.it closes #1
@tiero @altafan please, can u review this (consider this as a proof of concept, not a polished work I think the full node needs extra work to be a "real" full node for instance)