-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Where to keep TxConfidenceTable
if not in Context?
#2531
Comments
Why not
bitcoinj/core/src/main/java/org/bitcoinj/core/PeerGroup.java Lines 1642 to 1646 in 0645a83
|
Good idea! However a PeerGroup doesn't always exist. One can instantiate a single Peer and receive events which should (potentially) have an effect on transaction confidences. |
It could be possible to share it between Peers in a PeerGroup and fallback to a private copy in a standalone Peer. |
Today, I investigated into the option to put TxConfidenceTable into PeerGroup. The Peer <> PeerGroup issue could be solved via listener (Peer broadcasts a "confidence event" up to PeerGroup, which manages confidences). Or maybe one of the existing event would match the problem already. Anyway, confidence is also needed in places where PeerGroup is far away, like Transaction and Wallet, and more. For those I don't see an easy solution. Except for using Network or NetworkParameters which is available almost everywhere. |
How about a "Blockchain" object? (perhaps
|
Note that "seen" is not a product of the blockchain, but of the P2P network. Of course the inverted argument is true for confidence in PeerGroup. Maybe it's a mistake to try and consolidate those two confidences (P2P based, blockchain based) in one TransactionConfidence object? Maybe we should split them and see if there is much (if any) communication between these two types? Wallet apps could use a convenience wrapper to re-bundle the confidences into one.
Transactions currently have some logic that depends on confidence. This then has to go elsewhere. |
I guess I consider the mempool (or a partial mempool or a partial list of pending transactions) to be a property of a blockchain (or a blockchain network.) If we don't want that to be part of the I also think we want to abstract from
I don't think splitting should be necessary.
Yes, I think we want to move that elsewhere anyway. (And perhaps "elsewhere" is a |
|
Yes. I think we should do this after creating a transaction interface and multiple (I propose 3) implementations: one for raw transaction data, one for transaction messages, and a third for wallet transactions. (There might also need to be some kind of transaction builder.) Our current transaction is used for all three roles and this (in my opinion) results in too much complexity and too many dependencies in one object. It might be OK for to have a I think we also need to define an object or interface that represents blockchain + mempool state. Currently this full state seems to be in a combination of existing objects including
I'd need to look at this a little more closely, but this could be a step we could take before deciding on or implementing some of the larger architectural changes/refactorings that I am proposing. |
I somewhat agree with this. I mean specifically for confidences I'm guessing we are only interested in confidences for transactions in our wallets. For transactions already past the |
Remember that a bitcoinj One example would be a light wallet that uses a server to track transaction confidence but uses bitcoinj objects in its GUI and a bitcoinj HD keychain for signing transactions. I can definitely imagine other wallets (or blockchain explorer apps) that might want to track transaction confidence. |
Completely agree with this. I guess I was a bit concerned that the new implementation might only track confidences for transactions in a |
Just having a browse and there seems like for the time being at least that |
I haven't forgotten about this issue and am hoping we can move forward with it eventually.
I also think the refactoring and simplification we've been doing for the 0.17 will help with refactoring |
TxConfidenceTable
currently is the point of truth for transaction confidences. It is meant to exist only one time per network.Transaction.getConfidence()
is only a proxy (with apparently some issues, see #1769).Currently,
TxConfidenceTable
resides in ourContext
so we have it available whenever we need to. However, this is in the way of making the context optional and used only for testing purposes. Unfortunately,TxConfidenceTable
is needed in production, there is quite some logic (and usually UI) depending on it.So the question is: where could
TxConfidenceTable
go?TxConfidenceTable
references whereever we need them is likely unfeasible, and is probably the reason Context was implemented in the first place. It would affect many methods of the call chain I assume.TxConfidenceTable
, possibly unexpected and thus introduce hard to detect bugs/inconsistencies. But this might actually be ok, sinceTxConfidenceTable
has weak refs anyway, and has a 1000 entry cap. So apps might already have to deal with spurious "losses of confidence". Still it doesn't feel good to me.TxConfidenceTable
a VM-scoped singleton. Since the table is addressed by tx hash, it could actually support multiple networks at the same time (hashes don't overlap). Still it doesn't feel good to me.Network
orNetworkParameters
come to mind, but we want to keepNetwork
immutable and get rid ofNetworkParameters
eventually. Is there some omnipresent object left I oversee?TxConfidenceTable
(ages ago) such that the individual transactions keep track of confidence again. But in this case we might get rid of the confidence depth first, see Rethink WalletEventListener.onTransactionConfidenceChanged #877 and WIP: Get rid of depth in TransactionConfidence. #1553. Also, we might need to make sure tx instances only exist once per transaction, otherwise we'd have multiple confidences for the same tx. Our quest to make txns immutable might come in handy here?This ticket is meant for discussing the various options.
The text was updated successfully, but these errors were encountered: