pub struct Transaction {
pub destination: Did,
pub tx_id: Uuid,
pub sequence: u64,
pub reply_via: Option<Did>,
pub data: Vec<u8>,
pub verification: MessageVerification,
}Expand description
All messages transmitted in RingsNetwork should be wrapped by Transaction.
It additionally offer destination, tx_id and verification.
Every reply to a transaction is addressed to the transaction’s origin, and
takes one of two routes. Only the successor answer a node needs while it has no
predecessor (FindSuccessorReport) first goes through reply_via when
the origin signed one; a connect-signaling reply retraces, hop by linked hop, the path its
request recorded (#947); every other report routes straight toward the origin. No other
return address exists, so a request can direct no reply at a third party except the one
bounded successor answer at the one peer the origin itself named, which receives it whole
and hands it on only over a direct link to the origin (see crate::dht::delivery).
To transmit Transaction in RingsNetwork, user should build
MessagePayload and use PayloadSender to send.
Fields§
§destination: DidThe destination of this message.
tx_id: UuidThe transaction ID. Remote peer should use same tx_id when response.
sequence: u64Monotonic sequence inside the origin account’s destination-scoped stream.
reply_via: Option<Did>The peer the origin’s successor answers (FindSuccessorReport) return through while no
node is known to route to the origin: its nearest linked successor whenever it has no
predecessor, i.e. while it joins and again after its predecessor departs until a new one
notifies it; None otherwise. Signed with the rest of the transaction, so only the
origin chooses it.
data: Vec<u8>data
verification: MessageVerificationThis field holds a signature from a node, which is used to prove that the transaction was created by that node.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new<T>(
destination: Did,
tx_id: Uuid,
sequence: u64,
reply_via: Option<Did>,
data: T,
signer: MessageSigner<impl Borrow<DelegateeKey>>,
) -> Result<Transaction, Error>where
T: Serialize,
pub fn new<T>(
destination: Did,
tx_id: Uuid,
sequence: u64,
reply_via: Option<Did>,
data: T,
signer: MessageSigner<impl Borrow<DelegateeKey>>,
) -> Result<Transaction, Error>where
T: Serialize,
Wrap data: serialize it with rings_codec::serialize, then sign it, reply_via
included, with signer. reply_via names the peer the origin’s successor answers
return through; a reply, or any transaction whose origin has a predecessor, names
None.
Sourcepub fn origin(&self) -> Did
pub fn origin(&self) -> Did
The origin of this transaction: the account that authorized the session it is signed
by, i.e. MessageVerificationExt::signer under the name the routing layer uses for it.
This is the ring position a request is authorized against and the address its report is
routed to; it is never the session id, which names a key, not a node.
Sourcepub fn class(&self) -> Result<MessageCategory, Error>
pub fn class(&self) -> Result<MessageCategory, Error>
Traffic class implied by this transaction’s signed data: the class of the message kind it carries. Sender and receiver both derive a stream’s class this way, so the class needs no field of its own on the wire.
Sourcepub fn stream_key(&self, network_id: u32) -> Result<StreamKey, Error>
pub fn stream_key(&self, network_id: u32) -> Result<StreamKey, Error>
Destination-scoped stream identity under the receiver’s overlay: one sequence stream
per (origin, destination, class).
Sourcepub fn digest(&self) -> Result<TransactionDigest, Error>
pub fn digest(&self) -> Result<TransactionDigest, Error>
Digest of this exact signed transaction, including its delegation and signature.
Sourcepub fn data<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn data<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Deserializes the data field into a T instance.
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Transaction
impl Debug for Transaction
Source§impl<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Transaction, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Transaction, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Transaction
Source§impl MessageVerificationExt for Transaction
impl MessageVerificationExt for Transaction
Source§const DOMAIN_TAG: DomainTag = TRANSACTION_DOMAIN_TAG
const DOMAIN_TAG: DomainTag = TRANSACTION_DOMAIN_TAG
SigningDomain of Self::verification.Source§fn verification(&self) -> &MessageVerification
fn verification(&self) -> &MessageVerification
Source§fn is_expired(&self) -> bool
fn is_expired(&self) -> bool
Source§fn verify_at(&self, network_id: u32, at_ms: u128) -> bool
fn verify_at(&self, network_id: u32, at_ms: u128) -> bool
at_ms: its proof was live then, its session was
authorized and live then, and the signature was issued for this message family inside
the overlay network_id. Read moreSource§impl PartialEq for Transaction
impl PartialEq for Transaction
Source§impl Serialize for Transaction
impl Serialize for Transaction
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Transaction
Auto Trait Implementations§
impl Forget for Transaction
impl Freeze for Transaction
impl Move for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for T
impl<T> MaybeSendSync for T
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.