jito_searcher_client/
convert.rs

1//! Contains utility functions convert to/from protos and Rust structs.
2
3use bincode::serialize;
4use jito_protos::packet::{Meta as ProtoMeta, Packet as ProtoPacket};
5use solana_sdk::transaction::{Transaction, VersionedTransaction};
6/// Converts a VersionedTransaction to a protobuf packet
7///
8pub fn proto_packet_from_versioned_tx(tx: &VersionedTransaction) -> ProtoPacket {
9  let data = serialize(tx).expect("serializes");
10  let size = data.len() as u64;
11  ProtoPacket {
12    data,
13    meta: Some(ProtoMeta {
14      size,
15      addr: "".to_string(),
16      port: 0,
17      flags: None,
18      sender_stake: 0,
19    }),
20  }
21}
22
23pub fn proto_packet_from_tx(tx: &Transaction) -> ProtoPacket {
24  let data = serialize(tx).expect("serializes");
25  let size = data.len() as u64;
26  ProtoPacket {
27    data,
28    meta: Some(ProtoMeta {
29      size,
30      addr: "".to_string(),
31      port: 0,
32      flags: None,
33      sender_stake: 0,
34    }),
35  }
36}