Ana içeriğe atla

Parametreler

Bu metod herhangi bir parametre almaz.

Yanıt

result
object

Kod Örnekleri

Temel İstek

curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getHighestSnapshotSlot"
}'

web3.js Kullanımı

import { Connection } from '@solana/web3.js';

const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');

// Get highest snapshot slot
const snapshotSlot = await connection.getHighestSnapshotSlot();
console.log('Highest full snapshot slot:', snapshotSlot.full);
if (snapshotSlot.incremental !== null) {
  console.log('Highest incremental snapshot slot:', snapshotSlot.incremental);
}

// Check snapshot availability
async function checkSnapshotAvailability() {
  const snapshotSlot = await connection.getHighestSnapshotSlot();
  const currentSlot = await connection.getSlot();
  
  return {
    fullSnapshotAvailable: snapshotSlot.full > 0,
    incrementalSnapshotAvailable: snapshotSlot.incremental !== null,
    fullSnapshotSlot: snapshotSlot.full,
    incrementalSnapshotSlot: snapshotSlot.incremental,
    currentSlot,
    fullSnapshotAge: currentSlot - snapshotSlot.full,
    incrementalSnapshotAge: snapshotSlot.incremental ? currentSlot - snapshotSlot.incremental : null
  };
}

Notlar

  1. En yüksek anlık görüntü slotları hakkında bilgi döndürür
  2. Tam anlık görüntüler eksiksiz defter durumunu içerir
  3. Artımlı anlık görüntüler son tam anlık görüntüden bu yana değişiklikleri içerir
  4. Artımlı anlık görüntüler tüm düğümlerde mevcut olmayabilir
  5. Mevcut durumdan okuduğu için yanıt anında gelir

En İyi Uygulamalar

  1. Anlık görüntü kullanılabilirliğini belirlemek için bu metodu kullanın
  2. İşlemler planlarken anlık görüntü yaşını göz önünde bulundurun
  3. RPC yükünü azaltmak için uygun durumlarda sonuçları önbelleğe alın
  4. Artımlı anlık görüntülerin mevcut olmadığı durumları yönetin
  5. Diğer anlık görüntü metodlarıyla birlikte kullanın

Yaygın Hatalar

KodMesajÇözüm
-32601Method not foundBir Solana RPC düğümüne bağlı olduğunuzu doğrulayın
-32007Snapshot information unavailableDüğüm başlatılıyor veya senkronize ediliyor olabilir

Kullanım Senaryoları

  1. Anlık Görüntü Analizi
    interface SnapshotMetrics {
      fullSnapshot: {
        slot: number;
        age: number;
        available: boolean;
      };
      incrementalSnapshot: {
        slot: number | null;
        age: number | null;
        available: boolean;
      };
      currentSlot: number;
    }
    
    async function analyzeSnapshots(): Promise<SnapshotMetrics> {
      const snapshotSlot = await connection.getHighestSnapshotSlot();
      const currentSlot = await connection.getSlot();
      
      return {
        fullSnapshot: {
          slot: snapshotSlot.full,
          age: currentSlot - snapshotSlot.full,
          available: snapshotSlot.full > 0
        },
        incrementalSnapshot: {
          slot: snapshotSlot.incremental,
          age: snapshotSlot.incremental ? currentSlot - snapshotSlot.incremental : null,
          available: snapshotSlot.incremental !== null
        },
        currentSlot
      };
    }
    
  2. Anlık Görüntü İzleme
    interface SnapshotAlert {
      type: 'full' | 'incremental';
      message: string;
      currentSlot: number;
      snapshotSlot: number;
      age: number;
    }
    
    async function monitorSnapshots(maxAge: number): Promise<SnapshotAlert[]> {
      const snapshotSlot = await connection.getHighestSnapshotSlot();
      const currentSlot = await connection.getSlot();
      const alerts: SnapshotAlert[] = [];
      
      if (snapshotSlot.full > 0) {
        const fullAge = currentSlot - snapshotSlot.full;
        if (fullAge > maxAge) {
          alerts.push({
            type: 'full',
            message: `Full snapshot is ${fullAge} slots old`,
            currentSlot,
            snapshotSlot: snapshotSlot.full,
            age: fullAge
          });
        }
      }
      
      if (snapshotSlot.incremental !== null) {
        const incrementalAge = currentSlot - snapshotSlot.incremental;
        if (incrementalAge > maxAge) {
          alerts.push({
            type: 'incremental',
            message: `Incremental snapshot is ${incrementalAge} slots old`,
            currentSlot,
            snapshotSlot: snapshotSlot.incremental,
            age: incrementalAge
          });
        }
      }
      
      return alerts;
    }
    
  3. Anlık Görüntü Doğrulaması
    async function verifySnapshotAvailability() {
      const snapshotSlot = await connection.getHighestSnapshotSlot();
      const currentSlot = await connection.getSlot();
      
      if (snapshotSlot.full === 0) {
        throw new Error('No full snapshots available');
      }
      
      const fullAge = currentSlot - snapshotSlot.full;
      if (fullAge > 100000) { // Alert if snapshot is more than 100k slots old
        console.warn(`Full snapshot is ${fullAge} slots old`);
      }
      
      if (snapshotSlot.incremental === null) {
        console.warn('No incremental snapshots available');
      } else {
        const incrementalAge = currentSlot - snapshotSlot.incremental;
        if (incrementalAge > 10000) { // Alert if incremental snapshot is more than 10k slots old
          console.warn(`Incremental snapshot is ${incrementalAge} slots old`);
        }
      }
      
      return {
        fullSnapshot: snapshotSlot.full,
        incrementalSnapshot: snapshotSlot.incremental,
        currentSlot,
        fullAge,
        incrementalAge: snapshotSlot.incremental ? currentSlot - snapshotSlot.incremental : null
      };
    }