-
Notifications
You must be signed in to change notification settings - Fork 329
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
[chain] It should be easy to get the transaction in canonical order #1333
Comments
Can we move this to a post-1.0 milestone? it looks like a feature that can be added with a new function without breaking any of the existing apis. |
I think we should rename For Esplora/Electrum chain sources, we should make sure that a single update should only introduce one |
Is this a proposal to bring I think the flaw in my original proposal is that I am assuming that all changesets will be played back one by one. If they are aggregated then you would miss all the earlier // tx_graph.rs
#[must_use]
pub struct ChangeSet<A = ()> {
/// Added transactions.
pub txs: BTreeSet<Arc<Transaction>>,
/// Added txouts.
pub txouts: BTreeMap<OutPoint, TxOut>,
/// Added anchors.
pub anchors: BTreeSet<(A, Txid)>,
/// Added last-seen unix timestamps of transactions.
pub seen_in_mempool: BTreeMap<Txid, SeenInMempool>,
}
#[derive(Debug, Clone, PartialEq, Default)]
#[cfg_attr(
feature = "serde",
derive(serde::Deserialize, serde::Serialize),
serde(crate = "serde_crate")
)]
pub struct SeenInMempool {
first_seen: u64,
elapsed_since: u64,
}
impl SeenInMempool {
pub fn last_seen(&self) -> u64 {
self.first_seen.saturating_add(self.elapsed_since)
}
}
impl Append for SeenInMempool {
fn append(&mut self, other: Self) {
let last_seen = self.last_seen().max(other.last_seen());
let first_seen = self.first_seen.min(other.first_seen);
self.first_seen = first_seen;
self.elapsed_since = last_seen - first_seen;
}
fn is_empty(&self) -> bool {
false
}
} The idea that
I don't understand motivation for this. Why would it be helpful to tiebreak by |
@LLFourn My only complaint is that The idea with The downsides of the solution you suggested, is if the caller doesn't sync/scan very frequently, which would result in many unconfirmed txs to have the same Therefore, I'm in favour of your solution. |
@LLFourn mentioned that it's good practice to set |
So I was looking at this and to make the whole idea work we really need to block confirmation time to be communicated to the Another question is how to interpret the block confirmation time (which can vary by a few mins from actual confirmation time). I think the correct thing to do is if you've seen it in the mempool you should probably ignore the block confirmation time. In other words, try not shift the order too much. I guess the question is what if you haven't seen it in the mempool and it gets confirmed but the timestamp is a few minutes ago. Do you insert this straight to confirmation transaction earlier than a transaction you've just seen. Perhaps some kind of rule of thumb is the most useful: if the confirmation block is more than X mins earlier than the current time then it gets confirmed at that earlier time otherwise, current time. |
So as ordered by most recent to oldest vise versa
What do we mean by this?
first_seen
which stores the first time you see the tx. Ordered byfirst_seen
and tiebroken by confirmation height should give a nice consistent list of transactions that doesn't switch order too much. Note this wouldn't changeChangeSet
behavior at all since we already havelast_seen
.The text was updated successfully, but these errors were encountered: