fix stratum tree branch level
This commit is contained in:
parent
23713a11c2
commit
cac62765a1
@ -48,14 +48,16 @@ function parseTag(scriptSig: string): string {
|
|||||||
return (ascii.match(/\/.*\//)?.[0] || ascii).trim();
|
return (ascii.match(/\/.*\//)?.[0] || ascii).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMerkleBranchIds(merkleBranches: string[], numBranches: number): string[] {
|
function getMerkleBranchIds(merkleBranches: string[], numBranches: number, poolId: number): string[] {
|
||||||
let lastHash = '';
|
let lastHash = '';
|
||||||
const ids: string[] = [];
|
const ids: string[] = [];
|
||||||
for (let i = 0; i < numBranches; i++) {
|
for (let i = 0; i < numBranches; i++) {
|
||||||
if (merkleBranches[i]) {
|
if (merkleBranches[i]) {
|
||||||
lastHash = merkleBranches[i];
|
lastHash = merkleBranches[i];
|
||||||
}
|
|
||||||
ids.push(`${i}-${lastHash}`);
|
ids.push(`${i}-${lastHash}`);
|
||||||
|
} else {
|
||||||
|
ids.push(`${i}-${lastHash}-${poolId}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
@ -98,7 +100,7 @@ export class StratumList implements OnInit, OnDestroy {
|
|||||||
const numBranches = Math.max(...Object.values(rawJobs).map(job => job.merkleBranches.length));
|
const numBranches = Math.max(...Object.values(rawJobs).map(job => job.merkleBranches.length));
|
||||||
const jobs: Record<string, TaggedStratumJob> = {};
|
const jobs: Record<string, TaggedStratumJob> = {};
|
||||||
for (const [id, job] of Object.entries(rawJobs)) {
|
for (const [id, job] of Object.entries(rawJobs)) {
|
||||||
jobs[id] = { ...job, tag: parseTag(job.scriptsig), merkleBranchIds: getMerkleBranchIds(job.merkleBranches, numBranches) };
|
jobs[id] = { ...job, tag: parseTag(job.scriptsig), merkleBranchIds: getMerkleBranchIds(job.merkleBranches, numBranches, job.pool) };
|
||||||
}
|
}
|
||||||
if (Object.keys(jobs).length === 0) {
|
if (Object.keys(jobs).length === 0) {
|
||||||
return [];
|
return [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user