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