Simplify the code

This commit is contained in:
Lee Miller 2024-03-20 18:18:12 +02:00
parent 9eea54236b
commit 9c4c8940e8
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63

View File

@ -1,3 +1,4 @@
// Send newly generated message via a MiNode process running in background
const objects = require('bitmessage').objects, const objects = require('bitmessage').objects,
Address = require('bitmessage').Address; Address = require('bitmessage').Address;
@ -13,7 +14,7 @@ const zmq = require('zeromq');
spawn( spawn(
'minode', ['--request-queue', 'tcp://127.0.0.1:5566'], 'minode', ['--request-queue', 'tcp://127.0.0.1:5566'],
{timeout: 300000, killSignal: 'SIGQUIT'} {timeout: 100000, killSignal: 'SIGTERM'}
).stderr.on('data', (data) => { ).stderr.on('data', (data) => {
console.log(`${data}`); console.log(`${data}`);
}); });
@ -23,20 +24,19 @@ const zmq = require('zeromq');
console.log('sender:', sender.encode()); console.log('sender:', sender.encode());
console.log('recipient:', recipient.encode()); console.log('recipient:', recipient.encode());
var msg = await objects.msg.encodePayloadAsync({ objects.msg.encodePayloadAsync({
ttl: 1800, ttl: 1800,
from: sender, from: sender,
to: recipient, to: recipient,
message: 'The quick brown fox jumps over the lazy dog.', message: 'The quick brown fox jumps over the lazy dog.',
subject: 'hello', subject: 'hello',
encoding: 2, encoding: 2
friend: true }).then(function (msg) {
});
console.log('msg:', msg.toString('hex')); console.log('msg:', msg.toString('hex'));
console.log('Sending the msg...');
console.log('Sending the msg');
sock.send(Buffer.concat([ sock.send(Buffer.concat([
Buffer.from('msg', 'ascii'), Buffer.from('00', 'hex'), msg Buffer.from('msg', 'ascii'), Buffer.from('00', 'hex'), msg
])); ]));
});
})(); })();