We have been working towards this goal for years now, but I think we can deprecate Context as part of the 0.18 release.
There are 5 fields in Context:
boolean relaxProofOfWork -- only used in Block.checkProofOfWork() and only used for unit testing.
int eventHorizon -- only used in Wallet.notifyNewBestBlock()
boolean ensureMinRequiredFee -- only used in building SendRequest instances
Coin feePerKb-- only used in building SendRequest instances
TxConfidenceTable txConfidenceTable -- used in Wallet, Peer, PeerGroup (indirectly), and Transaction
This issue is a tracking issue for a stepwise deprecation and removal of Context and its use as a ThreadLocal. The steps should look roughly like.
- Eliminating all use of
Context within bitcoinj focusing on the 5 fields above. For backwards-compatibility we can probably leave the getters for these five fields and have them provide the instances/data that are now stored elsewhere.
- Remove the requirement for and use of
Context as a ThreadLocal for normal usage (i.e. everywhere but in the tests)
- Remove the the usage of
ThreadLocal Context in the tests
- Deprecate all
public references to Context --- hopefully this can be included in Release 0.18.
- Remove the
Context class entirely.
We have been working towards this goal for years now, but I think we can deprecate
Contextas part of the 0.18 release.There are 5 fields in
Context:boolean relaxProofOfWork-- only used inBlock.checkProofOfWork()and only used for unit testing.int eventHorizon-- only used inWallet.notifyNewBestBlock()boolean ensureMinRequiredFee-- only used in buildingSendRequestinstancesCoin feePerKb-- only used in buildingSendRequestinstancesTxConfidenceTable txConfidenceTable-- used inWallet,Peer,PeerGroup(indirectly), andTransactionThis issue is a tracking issue for a stepwise deprecation and removal of
Contextand its use as aThreadLocal. The steps should look roughly like.Contextwithin bitcoinj focusing on the 5 fields above. For backwards-compatibility we can probably leave the getters for these five fields and have them provide the instances/data that are now stored elsewhere.Contextas aThreadLocalfor normal usage (i.e. everywhere but in the tests)ThreadLocalContextin the testspublicreferences toContext--- hopefully this can be included in Release 0.18.Contextclass entirely.