standardize formatting

This commit is contained in:
Alex Bosworth 2023-05-04 08:00:25 -07:00
parent 75755f41b6
commit d119b90232
No known key found for this signature in database
GPG key ID: E80D2F3F311FD87E
2 changed files with 15 additions and 9 deletions

1
bos
View file

@ -108,6 +108,7 @@ prog
.help('Default filter scope: channels_count > 9')
.help('To only advertise to direct peers use --max-hops 0')
.help('To avoid advertising to direct peers use --min-hops 1')
.help('Multiple --tag is supported to advertise across multiple tags')
.option('--budget <budget>', 'Spending amount to allow for advertising', INT)
.option('--dryrun', 'Avoid actually sending advertisements')
.option('--filter <expression>', 'Require node match condition', REPEATABLE)

View file

@ -62,6 +62,7 @@ const utf8AsHex = utf8 => Buffer.from(utf8, 'utf8').toString('hex');
[message]: <Message To Send String>
[max_hops]: <Maxmimum Relaying Nodes Number>
[min_hops]: <Minimum Relaying Nodes Number>
tags: [<Tag Name String>]
}
*/
module.exports = (args, cbk) => {
@ -69,14 +70,14 @@ module.exports = (args, cbk) => {
return asyncAuto({
// Check arguments
validate: cbk => {
if (!args.fs) {
return cbk([400, 'ExpectedFileSystemToAdvertise']);
}
if (!isArray(args.filters)) {
return cbk([400, 'ExpectedArrayOfFiltersToAdvertise']);
}
if (!args.fs) {
return cbk([400, 'ExpectedFileSystemMethodsToAdvertise']);
}
if (!args.lnd) {
return cbk([400, 'ExpectedAuthenticatedLndToAdvertise']);
}
@ -85,6 +86,10 @@ module.exports = (args, cbk) => {
return cbk([400, 'ExpectedWinstonLoggerToAdvertise']);
}
if (!isArray(args.tags)) {
return cbk([400, 'ExpectedArrayOfTagsToAdvertiseTo']);
}
return cbk();
},
@ -98,6 +103,11 @@ module.exports = (args, cbk) => {
return getChannels({lnd: args.lnd}, cbk);
}],
// Get the local identity to compose the ad message
getIdentity: ['validate', ({}, cbk) => {
return getWalletInfo({lnd: args.lnd}, cbk);
}],
// Get the list of tags and filter them.
getTags: ['getIdentity', ({getIdentity}, cbk) => {
// Exit early when there are no tags specified to advertise to
@ -132,11 +142,6 @@ module.exports = (args, cbk) => {
});
}],
// Get the local identity to compose the ad message
getIdentity: ['validate', ({}, cbk) => {
return getWalletInfo({lnd: args.lnd}, cbk);
}],
// Get the graph to use to find candidates to send ads to
getGraph: ['getChannels', 'getTags', ({getChannels, getTags}, cbk) => {
// Exit early when when advertising to tags.