(feat):add private variant in tx origin (#4059)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Supernovahs.eth
2023-08-04 19:27:14 +05:30
committed by GitHub
parent 689b9d6358
commit ff1ef294cc
3 changed files with 15 additions and 3 deletions

View File

@@ -188,7 +188,11 @@ impl<T: PoolTransaction> TransactionValidator for MockTransactionValidator<T> {
balance: Default::default(),
state_nonce: 0,
transaction,
propagate: if origin.is_local() { self.propagate_local } else { true },
propagate: match origin {
TransactionOrigin::External => true,
TransactionOrigin::Local => self.propagate_local,
TransactionOrigin::Private => false,
},
}
}
}

View File

@@ -404,6 +404,11 @@ pub enum TransactionOrigin {
/// This is usually considered an "untrusted" source, for example received from another in the
/// network.
External,
/// Transaction is originated locally and is intended to remain private.
///
/// This type of transaction should not be propagated to the network. It's meant for
/// private usage within the local node only.
Private,
}
// === impl TransactionOrigin ===

View File

@@ -461,8 +461,11 @@ where
state_nonce: account.nonce,
transaction,
// by this point assume all external transactions should be propagated
propagate: matches!(origin, TransactionOrigin::External) ||
self.propagate_local_transactions,
propagate: match origin {
TransactionOrigin::External => true,
TransactionOrigin::Local => self.propagate_local_transactions,
TransactionOrigin::Private => false,
},
}
}
}