@ethersphere/bee-js 6.2.0 → 6.4.0
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.
- package/dist/cjs/bee-debug.js +7 -0
- package/dist/cjs/modules/debug/status.js +11 -1
- package/dist/cjs/utils/expose.js +20 -16
- package/dist/cjs/utils/stamps.js +45 -7
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +7 -0
- package/dist/mjs/modules/debug/status.js +9 -0
- package/dist/mjs/utils/expose.js +5 -5
- package/dist/mjs/utils/stamps.js +40 -10
- package/dist/types/bee-debug.d.ts +5 -1
- package/dist/types/modules/debug/status.d.ts +2 -1
- package/dist/types/types/debug.d.ts +12 -0
- package/dist/types/types/index.d.ts +17 -5
- package/dist/types/utils/expose.d.ts +5 -5
- package/dist/types/utils/stamps.d.ts +31 -7
- package/package.json +1 -1
package/dist/mjs/bee-debug.js
CHANGED
|
@@ -225,6 +225,13 @@ export class BeeDebug {
|
|
|
225
225
|
assertRequestOptions(options);
|
|
226
226
|
return settlements.getAllSettlements(this.getRequestOptionsForCall(options));
|
|
227
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Get status of node
|
|
230
|
+
*/
|
|
231
|
+
async getStatus(options) {
|
|
232
|
+
assertRequestOptions(options);
|
|
233
|
+
return status.getDebugStatus(this.getRequestOptionsForCall(options));
|
|
234
|
+
}
|
|
228
235
|
/**
|
|
229
236
|
* Get health of node
|
|
230
237
|
*/
|
|
@@ -6,8 +6,17 @@ export const SUPPORTED_API_VERSION = '4.0.0';
|
|
|
6
6
|
export const SUPPORTED_DEBUG_API_VERSION = '4.0.0';
|
|
7
7
|
export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.substring(0, SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
|
|
8
8
|
const NODE_INFO_URL = 'node';
|
|
9
|
+
const STATUS_URL = 'status';
|
|
9
10
|
const HEALTH_URL = 'health';
|
|
10
11
|
const READINESS_URL = 'readiness';
|
|
12
|
+
export async function getDebugStatus(requestOptions) {
|
|
13
|
+
const response = await http(requestOptions, {
|
|
14
|
+
method: 'get',
|
|
15
|
+
url: STATUS_URL,
|
|
16
|
+
responseType: 'json'
|
|
17
|
+
});
|
|
18
|
+
return response.data;
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* Get health of node
|
|
13
22
|
*
|
package/dist/mjs/utils/expose.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { getCollectionSize } from "./collection.js";
|
|
2
2
|
export { getFolderSize } from "./collection.node.js";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
3
|
+
export { assertBytes, assertFlexBytes, bytesAtOffset, bytesEqual, flexBytesAtOffset, isBytes, isFlexBytes } from "./bytes.js";
|
|
4
|
+
export { assertHexString, assertPrefixedHexString, bytesToHex, hexToBytes, intToHex, isHexString, makeHexString } from "./hex.js";
|
|
5
|
+
export { ethToSwarmAddress, fromLittleEndian, isHexEthAddress, makeEthAddress, makeEthereumWalletSigner, makeHexEthAddress, toLittleEndian } from "./eth.js";
|
|
6
|
+
export { isNodeReadable, isReadable, isReadableStream, normalizeToReadableStream, readableNodeToWeb, readableWebToNode } from "./stream.js";
|
|
7
7
|
export { keccak256Hash } from "./hash.js";
|
|
8
8
|
export { makeMaxTarget } from "./pss.js";
|
|
9
|
-
export { getStampUsage } from "./stamps.js";
|
|
9
|
+
export { getStampCostInBzz, getStampCostInPlur, getStampMaximumCapacityBytes, getStampTtlSeconds, getStampUsage } from "./stamps.js";
|
package/dist/mjs/utils/stamps.js
CHANGED
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* is small.
|
|
4
|
+
* For smaller depths (up to 20), this may provide less accurate results.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
* @param depth
|
|
9
|
-
* @param bucketDepth
|
|
6
|
+
* @returns {number} A number between 0 and 1 representing the usage of the postage batch.
|
|
10
7
|
*/
|
|
11
|
-
export function getStampUsage({
|
|
12
|
-
utilization,
|
|
13
|
-
depth,
|
|
14
|
-
bucketDepth
|
|
15
|
-
}) {
|
|
8
|
+
export function getStampUsage(utilization, depth, bucketDepth) {
|
|
16
9
|
return utilization / Math.pow(2, depth - bucketDepth);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Utility function that calculates the theoritical maximum capacity of a postage batch based on its depth.
|
|
13
|
+
*
|
|
14
|
+
* For smaller depths (up to 20), this may provide less accurate results.
|
|
15
|
+
*
|
|
16
|
+
* @returns {number} The maximum capacity of the postage batch in bytes.
|
|
17
|
+
*/
|
|
18
|
+
export function getStampMaximumCapacityBytes(depth) {
|
|
19
|
+
return 2 ** depth * 4096;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
23
|
+
*
|
|
24
|
+
* @returns {number} The cost of the postage batch in PLUR (10000000000000000 [1e16] PLUR = 1 BZZ)
|
|
25
|
+
*/
|
|
26
|
+
export function getStampCostInPlur(depth, amount) {
|
|
27
|
+
return 2 ** depth * amount;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
31
|
+
*
|
|
32
|
+
* @returns {number} The cost of the postage batch in BZZ (1 BZZ = 10000000000000000 [1e16] PLUR)
|
|
33
|
+
*/
|
|
34
|
+
export function getStampCostInBzz(depth, amount) {
|
|
35
|
+
const BZZ_UNIT = 10 ** 16;
|
|
36
|
+
return getStampCostInPlur(depth, amount) / BZZ_UNIT;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Utility function that calculates the TTL of a postage batch based on its amount, price per block and block time.
|
|
40
|
+
*
|
|
41
|
+
* For more accurate results, get the price per block and block time from the Bee node or the blockchain.
|
|
42
|
+
*
|
|
43
|
+
* @returns {number} The TTL of the postage batch in seconds.
|
|
44
|
+
*/
|
|
45
|
+
export function getStampTtlSeconds(amount, pricePerBlock = 24000, blockTime = 5) {
|
|
46
|
+
return amount * blockTime / pricePerBlock;
|
|
17
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, AllSettlements, BalanceResponse, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, ExtendedTag, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, PingResponse, PostageBatch, PostageBatchBuckets, RedistributionState, RemovePeerResponse, ReserveState, Settlements, Topology, TransactionHash, TransactionInfo, WalletBalance } from './types';
|
|
1
|
+
import type { Address, AllSettlements, BalanceResponse, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, DebugStatus, ExtendedTag, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, PingResponse, PostageBatch, PostageBatchBuckets, RedistributionState, RemovePeerResponse, ReserveState, Settlements, Topology, TransactionHash, TransactionInfo, WalletBalance } from './types';
|
|
2
2
|
import { BatchId, BeeOptions, CashoutOptions, PostageBatchOptions, Tag, TransactionOptions } from './types';
|
|
3
3
|
export declare class BeeDebug {
|
|
4
4
|
/**
|
|
@@ -113,6 +113,10 @@ export declare class BeeDebug {
|
|
|
113
113
|
* Get settlements with all known peers and total amount sent or received
|
|
114
114
|
*/
|
|
115
115
|
getAllSettlements(options?: BeeRequestOptions): Promise<AllSettlements>;
|
|
116
|
+
/**
|
|
117
|
+
* Get status of node
|
|
118
|
+
*/
|
|
119
|
+
getStatus(options?: BeeRequestOptions): Promise<DebugStatus>;
|
|
116
120
|
/**
|
|
117
121
|
* Get health of node
|
|
118
122
|
*/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BeeRequestOptions } from '../../index';
|
|
2
|
-
import type { Health, NodeInfo } from '../../types/debug';
|
|
2
|
+
import type { DebugStatus, Health, NodeInfo } from '../../types/debug';
|
|
3
3
|
import { BeeVersions } from '../../types/debug';
|
|
4
4
|
export declare const SUPPORTED_BEE_VERSION_EXACT = "1.13.0-f1067884";
|
|
5
5
|
export declare const SUPPORTED_API_VERSION = "4.0.0";
|
|
6
6
|
export declare const SUPPORTED_DEBUG_API_VERSION = "4.0.0";
|
|
7
7
|
export declare const SUPPORTED_BEE_VERSION: string;
|
|
8
|
+
export declare function getDebugStatus(requestOptions: BeeRequestOptions): Promise<DebugStatus>;
|
|
8
9
|
/**
|
|
9
10
|
* Get health of node
|
|
10
11
|
*
|
|
@@ -116,6 +116,18 @@ export interface PeerBalance {
|
|
|
116
116
|
export interface BalanceResponse {
|
|
117
117
|
balances: PeerBalance[];
|
|
118
118
|
}
|
|
119
|
+
export interface DebugStatus {
|
|
120
|
+
peer: string;
|
|
121
|
+
proximity: number;
|
|
122
|
+
beeMode: BeeModes;
|
|
123
|
+
reserveSize: number;
|
|
124
|
+
pullsyncRate: number;
|
|
125
|
+
storageRadius: number;
|
|
126
|
+
connectedPeers: number;
|
|
127
|
+
neighborhoodSize: number;
|
|
128
|
+
batchCommitment: number;
|
|
129
|
+
isReachable: boolean;
|
|
130
|
+
}
|
|
119
131
|
export interface Health {
|
|
120
132
|
status: 'ok';
|
|
121
133
|
version: string;
|
|
@@ -191,21 +191,33 @@ export interface UploadHeaders {
|
|
|
191
191
|
*/
|
|
192
192
|
export interface Tag {
|
|
193
193
|
/**
|
|
194
|
-
* Number of
|
|
194
|
+
* Number of chunks created by the splitter.
|
|
195
195
|
*/
|
|
196
|
-
|
|
196
|
+
split: number;
|
|
197
197
|
/**
|
|
198
|
-
* Number of chunks that
|
|
198
|
+
* Number of chunks that are already uploaded with same reference and same postage batch. These don't need to be synced again.
|
|
199
199
|
*/
|
|
200
|
-
|
|
200
|
+
seen: number;
|
|
201
201
|
/**
|
|
202
|
-
* Number of chunks that
|
|
202
|
+
* Number of chunks that were stored locally as they lie in the uploader node's neighborhood. This is only applicable for full nodes.
|
|
203
|
+
*/
|
|
204
|
+
stored: number;
|
|
205
|
+
/**
|
|
206
|
+
* Number of chunks sent on the network to peers as a part of the upload. Chunks could be sent multiple times because of failures or replication.
|
|
207
|
+
*/
|
|
208
|
+
sent: number;
|
|
209
|
+
/**
|
|
210
|
+
* Number of chunks that were pushed with a valid receipt. The receipt will also show if they were stored at the correct depth.
|
|
203
211
|
*/
|
|
204
212
|
synced: number;
|
|
205
213
|
/**
|
|
206
214
|
* Unique identifier
|
|
207
215
|
*/
|
|
208
216
|
uid: number;
|
|
217
|
+
/**
|
|
218
|
+
* Swarm hash of the uploaded data
|
|
219
|
+
*/
|
|
220
|
+
address: string;
|
|
209
221
|
/**
|
|
210
222
|
* When the upload process started
|
|
211
223
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { getCollectionSize } from './collection';
|
|
2
2
|
export { getFolderSize } from './collection.node';
|
|
3
|
-
export { Bytes, FlexBytes,
|
|
4
|
-
export { HexString, PrefixedHexString,
|
|
5
|
-
export { EthAddress,
|
|
6
|
-
export {
|
|
3
|
+
export { Bytes, FlexBytes, assertBytes, assertFlexBytes, bytesAtOffset, bytesEqual, flexBytesAtOffset, isBytes, isFlexBytes, } from './bytes';
|
|
4
|
+
export { HexString, PrefixedHexString, assertHexString, assertPrefixedHexString, bytesToHex, hexToBytes, intToHex, isHexString, makeHexString, } from './hex';
|
|
5
|
+
export { EthAddress, ethToSwarmAddress, fromLittleEndian, isHexEthAddress, makeEthAddress, makeEthereumWalletSigner, makeHexEthAddress, toLittleEndian, } from './eth';
|
|
6
|
+
export { isNodeReadable, isReadable, isReadableStream, normalizeToReadableStream, readableNodeToWeb, readableWebToNode, } from './stream';
|
|
7
7
|
export { keccak256Hash } from './hash';
|
|
8
8
|
export { makeMaxTarget } from './pss';
|
|
9
|
-
export { getStampUsage } from './stamps';
|
|
9
|
+
export { getStampCostInBzz, getStampCostInPlur, getStampMaximumCapacityBytes, getStampTtlSeconds, getStampUsage, } from './stamps';
|
|
@@ -1,12 +1,36 @@
|
|
|
1
|
-
import { PostageBatch } from '../types';
|
|
2
1
|
/**
|
|
3
2
|
* Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* is small.
|
|
4
|
+
* For smaller depths (up to 20), this may provide less accurate results.
|
|
7
5
|
*
|
|
8
|
-
* @
|
|
9
|
-
* @param depth
|
|
10
|
-
* @param bucketDepth
|
|
6
|
+
* @returns {number} A number between 0 and 1 representing the usage of the postage batch.
|
|
11
7
|
*/
|
|
12
|
-
export declare function getStampUsage(
|
|
8
|
+
export declare function getStampUsage(utilization: number, depth: number, bucketDepth: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Utility function that calculates the theoritical maximum capacity of a postage batch based on its depth.
|
|
11
|
+
*
|
|
12
|
+
* For smaller depths (up to 20), this may provide less accurate results.
|
|
13
|
+
*
|
|
14
|
+
* @returns {number} The maximum capacity of the postage batch in bytes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getStampMaximumCapacityBytes(depth: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
19
|
+
*
|
|
20
|
+
* @returns {number} The cost of the postage batch in PLUR (10000000000000000 [1e16] PLUR = 1 BZZ)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getStampCostInPlur(depth: number, amount: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
25
|
+
*
|
|
26
|
+
* @returns {number} The cost of the postage batch in BZZ (1 BZZ = 10000000000000000 [1e16] PLUR)
|
|
27
|
+
*/
|
|
28
|
+
export declare function getStampCostInBzz(depth: number, amount: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Utility function that calculates the TTL of a postage batch based on its amount, price per block and block time.
|
|
31
|
+
*
|
|
32
|
+
* For more accurate results, get the price per block and block time from the Bee node or the blockchain.
|
|
33
|
+
*
|
|
34
|
+
* @returns {number} The TTL of the postage batch in seconds.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getStampTtlSeconds(amount: number, pricePerBlock?: number, blockTime?: number): number;
|