@dignetwork/dig-sdk 0.0.1-alpha.45 → 0.0.1-alpha.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,7 +21,7 @@ class ContentServer {
|
|
|
21
21
|
// Method to get the content of a specified key from the peer, with optional challenge query
|
|
22
22
|
async getKey(key, rootHash, challengeHex) {
|
|
23
23
|
// Construct the base URL
|
|
24
|
-
let url = `http://${this.ipAddress}/chia.${this.storeId}.${rootHash}/${key}`;
|
|
24
|
+
let url = `http://${this.ipAddress}:${ContentServer.port}/chia.${this.storeId}.${rootHash}/${key}`;
|
|
25
25
|
// If a challenge is provided, append it as a query parameter
|
|
26
26
|
if (challengeHex) {
|
|
27
27
|
url += `?challenge=${challengeHex}`;
|
|
@@ -42,32 +42,32 @@ class ContentServer {
|
|
|
42
42
|
}
|
|
43
43
|
// Method to get the .well-known information
|
|
44
44
|
async getWellKnown() {
|
|
45
|
-
const url = `http://${this.ipAddress}/.well-known`;
|
|
45
|
+
const url = `http://${this.ipAddress}:${ContentServer.port}/.well-known`;
|
|
46
46
|
return this.fetchJson(url);
|
|
47
47
|
}
|
|
48
48
|
// Method to get the list of known stores
|
|
49
49
|
async getKnownStores() {
|
|
50
|
-
const url = `http://${this.ipAddress}/.well-known/stores`;
|
|
50
|
+
const url = `http://${this.ipAddress}:${ContentServer.port}/.well-known/stores`;
|
|
51
51
|
return this.fetchJson(url);
|
|
52
52
|
}
|
|
53
53
|
// Method to get the index of all stores
|
|
54
54
|
async getStoresIndex() {
|
|
55
|
-
const url = `http://${this.ipAddress}/`;
|
|
55
|
+
const url = `http://${this.ipAddress}:${ContentServer.port}/`;
|
|
56
56
|
return this.fetchJson(url);
|
|
57
57
|
}
|
|
58
58
|
// Method to get the index of keys in a store
|
|
59
59
|
async getKeysIndex() {
|
|
60
|
-
const url = `http://${this.ipAddress}/${this.storeId}`;
|
|
60
|
+
const url = `http://${this.ipAddress}:${ContentServer.port}/${this.storeId}`;
|
|
61
61
|
return this.fetchJson(url);
|
|
62
62
|
}
|
|
63
63
|
// Method to check if a specific key exists (HEAD request)
|
|
64
64
|
async headKey(key) {
|
|
65
|
-
const url = `http://${this.ipAddress}/${this.storeId}/${key}`;
|
|
65
|
+
const url = `http://${this.ipAddress}:${ContentServer.port}/${this.storeId}/${key}`;
|
|
66
66
|
return this.head(url);
|
|
67
67
|
}
|
|
68
68
|
// Method to check if a specific store exists (HEAD request)
|
|
69
69
|
async headStore(options) {
|
|
70
|
-
let url = `http://${this.ipAddress}/${this.storeId}`;
|
|
70
|
+
let url = `http://${this.ipAddress}:${ContentServer.port}/${this.storeId}`;
|
|
71
71
|
if (options?.hasRootHash) {
|
|
72
72
|
url += `?hasRootHash=${options.hasRootHash}`;
|
|
73
73
|
}
|
|
@@ -75,7 +75,7 @@ class ContentServer {
|
|
|
75
75
|
}
|
|
76
76
|
streamKey(key) {
|
|
77
77
|
return new Promise((resolve, reject) => {
|
|
78
|
-
const url = `http://${this.ipAddress}/${this.storeId}/${key}`;
|
|
78
|
+
const url = `http://${this.ipAddress}:${ContentServer.port}/${this.storeId}/${key}`;
|
|
79
79
|
const urlObj = new url_1.URL(url);
|
|
80
80
|
const requestOptions = {
|
|
81
81
|
hostname: urlObj.hostname,
|
|
@@ -135,7 +135,7 @@ class DigNetwork {
|
|
|
135
135
|
break;
|
|
136
136
|
const peerIp = digPeers[0];
|
|
137
137
|
const digPeer = new DigPeer_1.DigPeer(peerIp, storeId);
|
|
138
|
-
const storeResponse = await digPeer.
|
|
138
|
+
const storeResponse = await digPeer.propagationServer.headStore({
|
|
139
139
|
hasRootHash: rootHash,
|
|
140
140
|
});
|
|
141
141
|
console.log(peerIp, storeResponse.headers);
|