Skip to content

Commit

Permalink
Merge pull request #30 from DIG-Network/release/v0.0.1-alpha.33
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.33
  • Loading branch information
MichaelTaylor3D authored Sep 28, 2024
2 parents eebea1d + aa234f9 commit bc87ab6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.1-alpha.33](https://github.com/DIG-Network/dig-incentive-server/compare/v0.0.1-alpha.32...v0.0.1-alpha.33) (2024-09-28)

### [0.0.1-alpha.32](https://github.com/DIG-Network/dig-incentive-server/compare/v0.0.1-alpha.31...v0.0.1-alpha.32) (2024-09-28)

### [0.0.1-alpha.31](https://github.com/DIG-Network/dig-incentive-server/compare/v0.0.1-alpha.30...v0.0.1-alpha.31) (2024-09-27)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dig-incentive-server",
"version": "0.0.1-alpha.31",
"version": "0.0.1-alpha.33",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
38 changes: 24 additions & 14 deletions src/tasks/payouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
DigChallenge,
DataStore,
getStoresList,
Environment
Environment,
} from "@dignetwork/dig-sdk";
import { Mutex } from "async-mutex";
import { IncentiveProgram } from "../utils/IncentiveProgram";
Expand Down Expand Up @@ -110,21 +110,27 @@ const runIncentiveProgram = async (
console.error(
`Failed to connect to peer ${peerIp}: ${error.message}`
);
// await program.addToBlacklist(peerIp);
// await program.addToBlacklist(peerIp);
continue;
}

if (response.success) {
const peerGenerationHash = response.headers?.["x-generation-hash"];
console.log(
`Peer ${peerIp} generation hash: ${peerGenerationHash}, expected: ${rootHash}`
);

if (Environment.DEBUG) {
console.log(
`Peer ${peerIp} generation hash: ${peerGenerationHash}, expected: ${rootHash}`
);
}
if (peerGenerationHash === rootHash) {
console.log(`Peer ${peerIp} has correct generation hash.`);

const challengePromises = randomKeysHex.map(async (hexKey) => {
try {
console.log(`Generating challenge for key: ${hexKey}`);
if (Environment.DEBUG) {
console.log(`Generating challenge for key: ${hexKey}`);
}

const digChallenge = new DigChallenge(
program.storeId,
hexKey,
Expand All @@ -134,11 +140,13 @@ const runIncentiveProgram = async (
const challenge = await digChallenge.generateChallenge(seed);
const serializedChallenge =
DigChallenge.serializeChallenge(challenge);
console.log(
`Sending challenge to peer ${peerIp} for key ${hexToUtf8(
hexKey
)}`
);
if (Environment.DEBUG) {
console.log(
`Sending challenge to peer ${peerIp} for key ${hexToUtf8(
hexKey
)}`
);
}
const peerChallengeResponse =
await digPeer.contentServer.getKey(
hexToUtf8(hexKey),
Expand All @@ -147,9 +155,11 @@ const runIncentiveProgram = async (
);
const expectedChallengeResponse =
await digChallenge.createChallengeResponse(challenge);
console.log(
`Received response from peer ${peerIp}, expected response: ${expectedChallengeResponse}`
);
if (Environment.DEBUG) {
console.log(
`Received response from peer ${peerIp}, expected response: ${expectedChallengeResponse}`
);
}
return peerChallengeResponse === expectedChallengeResponse;
} catch (error: any) {
console.error(
Expand Down

0 comments on commit bc87ab6

Please sign in to comment.