biketrack-app/node_modules/@ethersphere/bee-js/dist/mjs/modules/debug/connectivity.js

89 lines
2.2 KiB
JavaScript
Raw Normal View History

2022-07-11 10:27:11 +02:00
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { http } from "../../utils/http.js";
export function getNodeAddresses(ky) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield http(ky, {
path: 'addresses',
responseType: 'json'
});
return response.data;
});
}
export function getPeers(ky) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield http(ky, {
path: 'peers',
responseType: 'json'
});
return response.data.peers || [];
});
}
export function getBlocklist(ky) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield http(ky, {
path: 'blocklist',
responseType: 'json'
});
return response.data.peers || [];
});
}
export function removePeer(ky, peer) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield http(ky, {
path: `peers/${peer}`,
responseType: 'json',
method: 'DELETE'
});
return response.data;
});
}
export function getTopology(ky) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield http(ky, {
path: `topology`,
responseType: 'json'
});
return response.data;
});
}
export function pingPeer(ky, peer) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield http(ky, {
path: `pingpong/${peer}`,
responseType: 'json',
method: 'POST'
});
return response.data;
});
}