Refactor blockchain dependency #59
Merged
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.
What does this PR do?
Uses Guice dependency injection to provide a Singleton instance of the Blockchain class. Blockchain no longer had a dependency on Wallet being created first, so can now be instantiated at the start of the system, and that really seems to make sense.
Injects the Blockchain dependency on the constructor of UTXOSet.
Injects individual dependencies into PeerBuilder instead of the whole injector, as the change to Blockchain makes this possible now.
Why are these changes required?
So much depends on the Blockchain and it feels natural to have this class launched as a single instance when the system launches.
UTXOSet has Blockchain as an absolute dependency (it'll NullPointer if reindex is called without Blockchain set), so it's nicer to inject on the UTXOSet constructor.
This PR has been tested by:
Extra details
I've put these changes in a separate PR, so they can be assessed independently from the added unit test coverage.
I'd suggest merging #58 before merging these changes.