stacks-blockchain-api
stacks-blockchain-api copied to clipboard
Duplicate results in `/extended/v2/pox/cycles/{cycle_number}/signers/{signer_key}/stackers`
Describe the bug
The results from /extended/v2/pox/cycles/{cycle_number}/signers/{signer_key}/stackers contain some stackers more than once.
To Reproduce
The following script gets dupes. You can try it with cycle 86 and signer public key 02877ce29ba35458b827a6ea18510b9058ae4c30e2c33d288f2982c13497caec6e
async function getDupes(cycleNumber: number, signerPublicKey: string) {
function makeEndpoint(
cycleNumber: number,
signerPublicKey: string,
offset: number,
limit: number,
) {
const baseUrl = "https://api.mainnet.hiro.so";
const path = `/extended/v2/pox/cycles/${cycleNumber}/signers/0x${signerPublicKey}/stackers?offset=${offset}&limit=${limit}`;
const endpoint = `${baseUrl}${path}`;
return endpoint;
}
type GetStackersForSignerInPoxCycleResponse = {
limit: number;
offset: number;
total: number;
results: Array<{
stacker_address: string;
stacked_amount: string;
pox_address: string;
stacker_type: "pooled" | "solo";
}>;
};
const stackersMap = new Map<string, bigint>();
let hasMore = true;
let offset = 0;
const limit = 200;
while (hasMore) {
const res = await fetch(
makeEndpoint(cycleNumber, signerPublicKey, offset, limit),
{
headers: {
"x-hiro-api-key": hiroApiKey,
},
},
);
const data = (await res.json()) as GetStackersForSignerInPoxCycleResponse;
const stackers = data.results;
for (const stacker of stackers) {
const stacksAddress = stacker.stacker_address;
const lockAmount = BigInt(stacker.stacked_amount);
if (stackersMap.get(stacksAddress)) {
console.log("Found repeat result from API");
console.log(" Existing entry:", stackersMap.get(stacksAddress));
console.log(" New entry:", stacksAddress, lockAmount);
} else {
stackersMap.set(stacksAddress, lockAmount);
}
}
offset += data.results.length;
hasMore = offset < data.total;
}
}
Expected behavior No dupes
Hey there, just checking whether it's worth brining this issue out of the backlog since it's still happening? For this last cycle 95, getting a few repeat entries still:
Found repeat result from API
Existing entry: 1499000000n
New entry: SP3Y40Y7KSVNAGAV4AEACET8WC2CH5ZS1TN436H0A 1499000000n
Found repeat result from API
Existing entry: 1499000000n
New entry: SP3GKWW70RNNXHCYHF8S93NSSV9GPR6N6XEX0CRV 1499000000n
:tada: This issue has been resolved in version 8.12.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket: