Parameters
This method does not take any parameters.
Response
The highest slot that can be retransmitted
Code Examples
Basic Request
curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getMaxRetransmitSlot"
}'
Using web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://rpc.orbitflare.com');
// Get max retransmit slot
const maxRetransmitSlot = await connection.getMaxRetransmitSlot();
console.log('Max retransmit slot:', maxRetransmitSlot);
// Check if a slot can be retransmitted
async function canRetransmitSlot(slot: number) {
const maxRetransmitSlot = await connection.getMaxRetransmitSlot();
return slot <= maxRetransmitSlot;
}
// Get retransmit range
async function getRetransmitRange() {
const maxRetransmitSlot = await connection.getMaxRetransmitSlot();
const firstAvailableBlock = await connection.getFirstAvailableBlock();
return {
startSlot: firstAvailableBlock,
endSlot: maxRetransmitSlot,
totalSlots: maxRetransmitSlot - firstAvailableBlock + 1
};
}
Notes
- Returns the highest slot that can be retransmitted
- Used to determine the range of slots available for retransmission
- The response is immediate as it reads from the current state
- Slots beyond this value cannot be retransmitted
- This value can change as the node prunes old data
Best Practices
- Use this method to determine retransmission availability
- Cache results when appropriate to reduce RPC load
- Consider the impact of slot pruning
- Monitor for changes in max retransmit slot
- Use in conjunction with other slot-related methods
Common Errors
| Code | Message | Solution |
|---|
| -32601 | Method not found | Verify you’re connected to a Solana RPC node |
| -32007 | Slot information unavailable | Node may be bootstrapping or syncing |
Use Cases
-
Retransmission Planning
interface RetransmitPlan {
startSlot: number;
endSlot: number;
totalSlots: number;
availableSlots: number[];
missingSlots: number[];
}
async function planRetransmission(
targetSlots: number[]
): Promise<RetransmitPlan> {
const maxRetransmitSlot = await connection.getMaxRetransmitSlot();
const firstAvailableBlock = await connection.getFirstAvailableBlock();
const availableSlots = targetSlots.filter(
slot => slot >= firstAvailableBlock && slot <= maxRetransmitSlot
);
const missingSlots = targetSlots.filter(
slot => slot < firstAvailableBlock || slot > maxRetransmitSlot
);
return {
startSlot: firstAvailableBlock,
endSlot: maxRetransmitSlot,
totalSlots: maxRetransmitSlot - firstAvailableBlock + 1,
availableSlots,
missingSlots
};
}
-
Slot Availability Monitoring
interface SlotAlert {
type: 'pruned' | 'unavailable';
message: string;
slot: number;
maxRetransmitSlot: number;
}
class SlotMonitor {
private previousMaxSlot: number | null = null;
async monitorSlots(
targetSlots: number[]
): Promise<SlotAlert[]> {
const maxRetransmitSlot = await connection.getMaxRetransmitSlot();
const alerts: SlotAlert[] = [];
// Check for pruned slots
if (this.previousMaxSlot !== null && maxRetransmitSlot < this.previousMaxSlot) {
alerts.push({
type: 'pruned',
message: `Slots ${maxRetransmitSlot + 1} to ${this.previousMaxSlot} have been pruned`,
slot: this.previousMaxSlot,
maxRetransmitSlot
});
}
// Check target slots availability
for (const slot of targetSlots) {
if (slot > maxRetransmitSlot) {
alerts.push({
type: 'unavailable',
message: `Slot ${slot} is beyond max retransmit slot`,
slot,
maxRetransmitSlot
});
}
}
this.previousMaxSlot = maxRetransmitSlot;
return alerts;
}
}
-
Historical Data Management
interface HistoricalData {
availableRange: {
start: number;
end: number;
total: number;
};
prunedSlots: number[];
availableSlots: number[];
metadata: {
timestamp: number;
maxRetransmitSlot: number;
};
}
async function manageHistoricalData(
targetRange: { start: number; end: number }
): Promise<HistoricalData> {
const maxRetransmitSlot = await connection.getMaxRetransmitSlot();
const firstAvailableBlock = await connection.getFirstAvailableBlock();
const availableSlots = [];
const prunedSlots = [];
for (let slot = targetRange.start; slot <= targetRange.end; slot++) {
if (slot >= firstAvailableBlock && slot <= maxRetransmitSlot) {
availableSlots.push(slot);
} else {
prunedSlots.push(slot);
}
}
return {
availableRange: {
start: firstAvailableBlock,
end: maxRetransmitSlot,
total: maxRetransmitSlot - firstAvailableBlock + 1
},
prunedSlots,
availableSlots,
metadata: {
timestamp: Date.now(),
maxRetransmitSlot
}
};
}