-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup setInterval in account fetch cache to avoid hanging Node process #651
Comments
I'll add context for those who can't click on the Discord link: SummaryCalling To Reproduce
import { init, lazyDistributorKey } from "@helium/lazy-distributor-sdk";
import { getPendingRewards, formTransaction } from "@helium/distributor-oracle";
import * as anchor from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import {
init as initHem,
keyToAssetKey,
} from "@helium/helium-entity-manager-sdk";
import { daoKey } from "@helium/helium-sub-daos-sdk";
import { HNT_MINT } from "@helium/spl-utils";
import yargs from "yargs";
async function run (args: any = process.argv) {
const yarg = yargs(args).options({
wallet: {
alias: "k",
describe: "Anchor wallet keypair",
type: "string",
required: true,
},
url: {
alias: "u",
describe: "Solana RPC API endpoint",
default: "https://api.mainnet-beta.solana.com",
},
});
const argv = await yarg.argv;
const hotspotB58 = "11F65cECrtEQksuH7HZQamRfGipL4xT4SX5anFy1uyw56Nmxe6h";
process.env.ANCHOR_WALLET = argv.wallet;
const providerConnection = anchor.AnchorProvider.local(argv.url);
anchor.setProvider(providerConnection);
const provider = anchor.getProvider() as anchor.AnchorProvider;
const program = await init(provider);
const hemProgram = await initHem(provider);
const iotMintId = "iotEVVZLEywoTn1QdwNPddxPWszn3zFhEot3MfL9fns";
const iotMint = new PublicKey(iotMintId);
const hntMint = daoKey(HNT_MINT)[0];
const lazyDistributorPkey = lazyDistributorKey(iotMint)[0];
const [keyToAssetK] = keyToAssetKey(hntMint, hotspotB58);
const keyToAsset = await hemProgram.account.keyToAssetV0.fetch(keyToAssetK);
const asset = keyToAsset.asset;
const rewards = getPendingRewards(program, lazyDistributorPkey, hntMint,
[hotspotB58]);
return rewards;
}
run().then(function (results) { console.log(results); });
Additional InfoUsing the nifty package
|
WorkaroundWhile not stable in the long run, you can use The danger in using this method is that it is not a stable long-term pattern to use. This method could cause future versions of the code to perform badly if they spawn important subprocesses that need to complete before shutdown. |
https://discord.com/channels/404106811252408320/1097632035155214567/1242201684487307384
The text was updated successfully, but these errors were encountered: