Skip to content

Instantly share code, notes, and snippets.

import { Connection } from "@solana/web3.js";
import SolanaNetworkHealth from "types/enums/SolanaNetworkHealth";
import getRecentAverageTps from "utils/solana/health/getRecentAverageTps";
const SOLANA_SLOW_TPS_CUTOFF = 1_250;
const SOLANA_DOWN_TPS_CUTOFF = 500;
export default async function getSolanaNetworkHealth(
connection: Connection,
minutesLookback: number,
// Old code
#[account]
pub struct FooAccount {
foo_num: u128,
}
// New code
#[account]
pub struct FooAccount {
foo_num: u128,
// Old code
#[account]
pub struct FooAccount {
pubkey: Option<Pubkey>,
}
// New code
#[account]
pub struct FooAccount {
pubkey: Option<Pubkey>,
// Old code
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
foo_account: Account<'info, FooAccount>,
bar_account: Account<'info, BarAccount>,
}
// New code
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
// Old code
pub fn test_ix<'info>(
ctx: Context<'_, '_, '_, 'info, TestIx<'info>>,
test1: Option<bool>,
test2: Option<bool>,
) -> Result<()> {
Ok(())
}
// New code
// Old code
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
foo_account: Account<'info, FooAccount>,
#[account(mut)]
bar_account: Account<'info, BarAccount>,
}
// New code
#[derive(Accounts)]
// Old code
#[derive(Accounts)]
pub struct TestIx<'info> {
account1: UncheckedAccount<'info>,
}
// New code
#[derive(Accounts)]
pub struct TestIx<'info> {
account1: UncheckedAccount<'info>,
// Old code
pub fn print_accounts<'info>(
ctx: Context<'_, '_, '_, 'info, PrintAccounts<'info>>,
) -> Result<()> {
Ok(())
}
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
foo_account: Account<'info, FooAccount>,
// Old code
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
foo_account: Account<'info, FooAccount>,
bar_account: Account<'info, BarAccount>,
}
// New code
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
// Old code
pub fn test_ix<'info>(
_ctx: Context<'_, '_, '_, 'info, TestIx<'info>>,
) -> Result<()> {
Ok(())
}
// New code
pub fn test_ix<'info>(
_ctx: Context<'_, '_, '_, 'info, TestIx<'info>>,