Shreds Access
AllenHark provides direct access to the Solana Turbine shred stream via UDP. This allows for the lowest possible latency when receiving block data.
Connection Details
To access the stream, you will be provided with:
- Endpoint IP: The IP address of the shred streamer.
- Port: The UDP port to listen on or connect to.
- Authentication: IP-based whitelisting (contact support to authorize your IP).
Data Format
The stream delivers standard Solana Shreds. You can use standard Solana libraries to deserialize and process these packets.
Usage Examples
Rust (UDP Listener)
This example demonstrates how to listen for UDP packets. You will need to use solana-ledger or similar crates to deserialize the actual shreds.
1use std::net::UdpSocket;
2
3fn main() -> std::io::Result<()> {
4 // Bind to the port provided by AllenHark
5 let socket = UdpSocket::bind("0.0.0.0:8001")?;
6
7 // If connecting to a specific stream source (optional, depending on setup)
8 // socket.connect("151.241.71.10:8001")?;
9
10 let mut buf = [0; 65535];
11 println!("Listening for shreds...");
12
13 loop {
14 let (amt, src) = socket.recv_from(&mut buf)?;
15 let shred_data = &buf[..amt];
16
17 println!("Received {} bytes from {}", amt, src);
18
19 // Process shred data here
20 // use solana_ledger::shred::Shred;
21 // let shred = Shred::new_from_serialized_shred(shred_data.to_vec()).unwrap();
22 }
23}Node.js (UDP Listener)
1const dgram = require('dgram');
2const server = dgram.createSocket('udp4');
3
4server.on('error', (err) => {
5 console.log(`server error:\n${err.stack}`);
6 server.close();
7});
8
9server.on('message', (msg, rinfo) => {
10 console.log(`Received ${msg.length} bytes from ${rinfo.address}:${rinfo.port}`);
11
12 // Process raw buffer 'msg'
13 // Requires custom deserialization logic or WASM bindings to Solana Rust crates
14});
15
16server.on('listening', () => {
17 const address = server.address();
18 console.log(`server listening ${address.address}:${address.port}`);
19});
20
21// Bind to the port provided by AllenHark
22server.bind(8001);Support
For assistance with shred deserialization or connection issues, please join our Discord.