Merge pull request #3 from arihantbansal/get-block-details

get tps
This commit is contained in:
ARYAN
2024-11-27 17:38:30 +05:30
committed by GitHub
4 changed files with 42 additions and 0 deletions

17
src/tools/get_tps.ts Normal file
View File

@@ -0,0 +1,17 @@
import { SolanaAgentKit } from "../index";
export async function getTPS(agent: SolanaAgentKit): Promise<number> {
const perfSamples = await agent.connection.getRecentPerformanceSamples();
if (
!perfSamples.length ||
!perfSamples[0]?.numTransactions ||
!perfSamples[0]?.samplePeriodSecs
) {
throw new Error("No performance samples available");
}
const tps = perfSamples[0].numTransactions / perfSamples[0].samplePeriodSecs;
return tps;
}

View File

@@ -7,3 +7,4 @@ export * from "./transfer";
export * from "./trade";
export * from "./register_domain";
export * from "./lend";
export * from "./get_tps";