tempo_primitives/reth_compat/transaction/
tt_signature.rs1use crate::transaction::tt_signature::{PrimitiveSignature, TempoSignature};
2use alloy_primitives::Bytes;
3
4impl reth_codecs::Compact for PrimitiveSignature {
5 fn to_compact<B>(&self, buf: &mut B) -> usize
6 where
7 B: alloy_rlp::BufMut + AsMut<[u8]>,
8 {
9 let bytes = self.to_bytes();
10 bytes.to_compact(buf)
11 }
12
13 fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) {
14 let (bytes, rest) = Bytes::from_compact(buf, len);
15 let signature = Self::from_bytes(&bytes)
16 .expect("Failed to decode PrimitiveSignature from compact encoding");
17 (signature, rest)
18 }
19}
20
21impl reth_codecs::Compact for TempoSignature {
22 fn to_compact<B>(&self, buf: &mut B) -> usize
23 where
24 B: alloy_rlp::BufMut + AsMut<[u8]>,
25 {
26 let bytes = self.to_bytes();
27 bytes.to_compact(buf)
28 }
29
30 fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) {
31 let (bytes, rest) = Bytes::from_compact(buf, len);
32 let signature = Self::from_bytes(&bytes)
33 .expect("Failed to decode TempoSignature from compact encoding");
34 (signature, rest)
35 }
36}