Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const midFile = storageDir + "mid-" + dateString(this.start);
const lowFile = storageDir + "low-" + dateString(this.start);
// Post the files to IPFS
ipfs.files.add([
{
path: highFile,
content: bson.serialize(this.pool.high)
},
{
path: midFile,
content: bson.serialize(this.pool.mid)
},
{
path: lowFile,
content: bson.serialize(this.pool.low)
},
], (err, files) => {
// Find the individual hashes
let lowHash = "";
let midHash = "";
let highHash = "";
// Load them from the IPFS results
for ( const file of files ) {
if ( file.path == highFile ) {
highHash = file.hash;
}
else if ( file.path == midFile ) {
midHash = file.hash;
}
const storageDir = this.storageFolder + "/merkle/";
// File locations for individual levels
const highFile = storageDir + "high-" + dateString(this.start);
const midFile = storageDir + "mid-" + dateString(this.start);
const lowFile = storageDir + "low-" + dateString(this.start);
// Post the files to IPFS
ipfs.files.add([
{
path: highFile,
content: bson.serialize(this.pool.high)
},
{
path: midFile,
content: bson.serialize(this.pool.mid)
},
{
path: lowFile,
content: bson.serialize(this.pool.low)
},
], (err, files) => {
// Find the individual hashes
let lowHash = "";
let midHash = "";
let highHash = "";
// Load them from the IPFS results
for ( const file of files ) {
if ( file.path == highFile ) {
highHash = file.hash;
const midMerkleTree = midMerkleTree.constructTree();
const lowMerkleTree = lowMerkleTree.constructTree();
// Store them
const storageDir = this.storageFolder + "/merkle/";
// File locations for individual levels
const highFile = storageDir + "high-" + dateString(this.start);
const midFile = storageDir + "mid-" + dateString(this.start);
const lowFile = storageDir + "low-" + dateString(this.start);
// Post the files to IPFS
ipfs.files.add([
{
path: highFile,
content: bson.serialize(this.pool.high)
},
{
path: midFile,
content: bson.serialize(this.pool.mid)
},
{
path: lowFile,
content: bson.serialize(this.pool.low)
},
], (err, files) => {
// Find the individual hashes
let lowHash = "";
let midHash = "";
let highHash = "";
self.send = function (v, fd) {
const ms = getMsgObj(v, fd);
debug('Process ' + process.pid + ' sending message: ' + util.inspect(ms));
s.send(BSON.serialize(ms), {binary: true, mask: true});
};
save(notes: Notes) {
const cachePath = path.join(this._dir, CACHE_FILENAME);
if (this._skipSave) {
try {
fs.unlinkSync(cachePath);
} catch (err) {
console.warn("textual-velocity: could not clear notes cache:", err);
}
} else {
try {
const data = BSON.serialize(notes);
fs.writeFileSync(cachePath, data);
} catch (err) {
console.warn("textual-velocity: could not cache notes:", err);
}
}
}
}
serialize(json) {
return BSON.serialize(json)
}
deserialize(data) {
static notifyCommandResp({productName, deviceName, command, requestId, ts, payload}){
var data = bson.serialize({
device_name: deviceName,
command: command,
request_id: requestId,
send_at: ts,
payload: payload
})
if(currentChannel != null){
currentChannel.publish(commandRespExchange, productName, data)
}
}
static notifyUpdateStatus({productName, deviceName, deviceStatus}){
var data = bson.serialize({
device_name: deviceName,
device_status: deviceStatus
})
if(currentChannel != null) {
currentChannel.publish(updateStatusExchange, productName, data, {
persistent: true
})
}
}
static notifyUploadData(message) {
var data = bson.serialize({
device_name: message.device_name,
payload: message.payload,
send_at: message.sendAt,
data_type: message.dataType,
message_id: message.message_id
})
if(currentChannel != null) {
currentChannel.publish(uploadDataExchange, message.product_name, data, {
persistent: true
})
}
}