Skip to content

Commit ebec380

Browse files
Merge pull request #118 from DIG-Network/release/v0.0.1-alpha.129
Release/v0.0.1 alpha.129
2 parents 1554afd + 827aeab commit ebec380

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
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.
44

5+
### [0.0.1-alpha.129](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.128...v0.0.1-alpha.129) (2024-10-04)
6+
7+
8+
### Features
9+
10+
* add ping network on update ([c7ebc6f](https://github.com/DIG-Network/dig-chia-sdk/commit/c7ebc6fc4ff04c880d0363d9079bca09256d789a))
11+
512
### [0.0.1-alpha.128](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.127...v0.0.1-alpha.128) (2024-10-04)
613

714

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dignetwork/dig-sdk",
3-
"version": "0.0.1-alpha.128",
3+
"version": "0.0.1-alpha.129",
44
"description": "",
55
"type": "commonjs",
66
"main": "./dist/index.js",

src/DigNetwork/DigNetwork.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ export class DigNetwork {
209209
}
210210
}
211211
}
212+
213+
DigNetwork.pingNetworkOfUpdate(this.dataStore.StoreId, rootInfo.root_hash);
212214
}
213215

214216
console.log("Syncing store complete.");

src/DigNetwork/PropagationServer.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,39 @@ export class PropagationServer {
8080
});
8181
}
8282

83+
/**
84+
* Ping the current peer about an update to the store, passing rootHash.
85+
* @param rootHash - The root hash for the store update.
86+
*/
87+
async getMyPublicIp(rootHash: string): Promise<void> {
88+
try {
89+
const httpsAgent = this.createHttpsAgent();
90+
const url = `https://${formatHost(this.ipAddress)}:${
91+
PropagationServer.port
92+
}/peer`;
93+
94+
const config: AxiosRequestConfig = {
95+
httpsAgent,
96+
headers: {
97+
"Content-Type": "application/json",
98+
},
99+
};
100+
101+
try {
102+
const response = await axios.get(url, config);
103+
console.log(green(`✔ Successfully pinged peer: ${this.ipAddress}`));
104+
105+
return response.data;
106+
} catch (error: any) {
107+
console.error(red(`✖ Failed to ping peer: ${this.ipAddress}`));
108+
console.error(red(error.message));
109+
throw error;
110+
}
111+
} catch (error: any) {
112+
console.error(red(error.message));
113+
}
114+
}
115+
83116
/**
84117
* Ping the current peer about an update to the store, passing rootHash.
85118
* @param rootHash - The root hash for the store update.

0 commit comments

Comments
 (0)