mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Minor library improvements. (#198)
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "json.h"
|
||||
|
||||
#define __HP_MMAP_BLOCK_SIZE 4096
|
||||
#define __HP_MMAP_BLOCK_ALIGN(x) (((x) + ((typeof(x))(__HP_MMAP_BLOCK_SIZE)-1)) & ~((typeof(x))(__HP_MMAP_BLOCK_SIZE)-1))
|
||||
#define __HP_MMAP_BLOCK_ALIGN(x) (((x) + ((off_t)(__HP_MMAP_BLOCK_SIZE)-1)) & ~((off_t)(__HP_MMAP_BLOCK_SIZE)-1))
|
||||
#define __HP_STREAM_MSG_HEADER_SIZE 4
|
||||
#define __HP_SEQPKT_MAX_SIZE 131072 // 128KB to support SEQ_PACKET sockets.
|
||||
#define HP_PEER_MSG_MAX_SIZE __HP_SEQPKT_MAX_SIZE
|
||||
|
||||
@@ -674,9 +674,10 @@
|
||||
|
||||
// Set sodium reference.
|
||||
async function initSodium() {
|
||||
if (sodium) // If already set, do nothing.
|
||||
if (sodium) { // If already set, do nothing.
|
||||
return;
|
||||
else if (isBrowser && window.sodium) { // If no parameter specified, try to get from window.sodium.
|
||||
}
|
||||
else if (isBrowser && window.sodium) { // browser (if sodium already loaded)
|
||||
sodium = window.sodium;
|
||||
}
|
||||
else if (isBrowser && !window.sodium) { // If sodium not yet loaded in browser, wait for sodium ready.
|
||||
@@ -693,26 +694,33 @@
|
||||
sodium = require('libsodium-wrappers');
|
||||
await sodium.ready;
|
||||
}
|
||||
else {
|
||||
throw "Sodium reference not found. Please include sodium js lib in browser scripts.";
|
||||
}
|
||||
}
|
||||
|
||||
// Set bson reference.
|
||||
function initBson() {
|
||||
if (bson) // If already set, do nothing.
|
||||
return;
|
||||
else if (isBrowser && window.BSON) // If no parameter specified, try to get from window.BSON.
|
||||
else if (isBrowser && window.BSON) // browser
|
||||
bson = window.BSON;
|
||||
else if (!isBrowser) // nodejs
|
||||
bson = require('bson');
|
||||
else
|
||||
throw "BSON reference not found.";
|
||||
}
|
||||
|
||||
// Set WebSocket reference.
|
||||
function initWebSocket() {
|
||||
if (WebSocket) // If already set, do nothing.
|
||||
return;
|
||||
else if (isBrowser && window.WebSocket) // If no parameter specified, try to get from window.WebSocket.
|
||||
else if (isBrowser && window.WebSocket) // browser
|
||||
WebSocket = window.WebSocket;
|
||||
else if (!isBrowser) // nodejs
|
||||
WebSocket = require('ws');
|
||||
else
|
||||
throw "WebSocket reference not found.";
|
||||
}
|
||||
|
||||
const hotPocketLib = {
|
||||
|
||||
Reference in New Issue
Block a user