gagliardetto / solana-go

Go SDK library and RPC client for the Solana Blockchain
Apache License 2.0
902 stars 260 forks source link

API can not work any more #244

Open benhaben opened 2 months ago

benhaben commented 2 months ago
package main

import (
    "log"
    "time"

    "context"
    "fmt"

    "github.com/gagliardetto/solana-go/rpc"
    "golang.org/x/time/rate"
)

func main() {
    cluster := rpc.MainNetBeta

    rpcClient := rpc.NewWithCustomRPCClient(rpc.NewWithLimiter(
        cluster.RPC,
        rate.Every(time.Second), // time frame
        5,                       // limit of requests per time frame
    ))

    // Get the recent blockhash:

    recent, err := rpcClient.GetLatestBlockhash(context.TODO(), rpc.CommitmentFinalized)
    if err != nil {
        log.Fatalf("Failed to get latest blockhash: %v", err)
    }

    fmt.Printf("  Blockhash: %s\n", recent.Value.Blockhash)
    fmt.Printf("  LastValidBlockHeight: %d\n", recent.Value.LastValidBlockHeight)
}

report error : Failed to get latest blockhash: rpc call getLatestBlockhash() on https://api.mainnet-beta.solana.com: Post "https://api.mainnet-beta.solana.com": read tcp 127.0.0.1:60388->127.0.0.1:33210: read: connection reset by peer

HyperMutekiXXX commented 5 days ago

same problem. did u solve it?

gagliardetto commented 2 days ago

Maybe your IP got blocked? It's public RPC.