cleanup and change sewit witness output to its own tx

This commit is contained in:
Ben
2023-07-02 19:22:33 -04:00
parent b147eff49a
commit b1800419c4
13 changed files with 886 additions and 117 deletions
+5 -6
View File
@@ -12,7 +12,7 @@ export class StratumV1ClientStatistics {
this.submissionCacheStart = new Date();
}
public async addSubmission(client: ClientEntity, targetDifficulty: number) {
public async addSubmission(client: ClientEntity, submissionHash: string, targetDifficulty: number) {
if (this.submissionCache.length > CACHE_SIZE) {
this.submissionCache.shift();
@@ -29,6 +29,7 @@ export class StratumV1ClientStatistics {
address: client.address,
clientName: client.clientName,
sessionId: client.sessionId,
submissionHash
});
}
@@ -37,7 +38,7 @@ export class StratumV1ClientStatistics {
// miner hasn't submitted shares in one minute
if (this.submissionCache.length == 0 && (new Date().getTime() - this.submissionCacheStart.getTime()) / 1000 > 60) {
return this.blpo2(clientDifficulty >> 1);
return this.nearestPowerOfTwo(clientDifficulty >> 1);
}
if (this.submissionCache.length < CACHE_SIZE) {
@@ -55,15 +56,14 @@ export class StratumV1ClientStatistics {
const targetDifficulty = difficultyPerSecond * TARGET_SUBMISSION_PER_SECOND;
if (clientDifficulty << 1 < targetDifficulty || clientDifficulty >> 1 > targetDifficulty) {
return this.blpo2(targetDifficulty)
return this.nearestPowerOfTwo(targetDifficulty)
}
return null;
}
private blpo2(val) {
private nearestPowerOfTwo(val) {
let x = val | (val >> 1);
x = x | (x >> 2);
x = x | (x >> 4);
@@ -86,5 +86,4 @@ export class StratumV1ClientStatistics {
return res;
}
}