From 3f2c441710e588b2b84b300b339c50b520a4b26c Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 1 Nov 2017 11:23:08 -0700 Subject: [PATCH] Decide on how to store list data on local FS --- bin/hushlist | 15 +++++++++++++++ lib/Hush/List.pm | 11 +++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/bin/hushlist b/bin/hushlist index 89133b6..9158fca 100755 --- a/bin/hushlist +++ b/bin/hushlist @@ -4,8 +4,10 @@ use warnings; use Try::Tiny; use lib 'lib'; use Hush::List; +use Data::Dumper; my $command = shift || help(); +# we only need one my $list = Hush::List->new; my $COMMANDS = { @@ -14,13 +16,26 @@ my $COMMANDS = { "remove" => \&remove, "send" => \&send, }; +run(); + sub help { print "It would be nice to give some help\n"; } + +sub new { + my $name = shift || ''; + die "Invalid hushlist name '$name' !" unless $name; + $list->new_list($name); + print "hushlist '$name' created, enjoy your private comms :)\n"; +} + sub run { + print "Running command $command\n"; my $cmd = $COMMANDS->{$command}; + if ($cmd) { + $cmd->(@ARGV); } else { help(); } diff --git a/lib/Hush/List.pm b/lib/Hush/List.pm index bbb46b5..af3129f 100644 --- a/lib/Hush/List.pm +++ b/lib/Hush/List.pm @@ -72,6 +72,11 @@ sub new_list { my $lists = $self->{lists}; # a list is simply a list of addresses, which can be looked up by name, and maybe some other metadata $lists->{$name} = { recipients => {} }; + + # ~/.hush/list/LIST_NAME/ + # ~/.hush/list/LIST_NAME/list.conf - list-specific config items + # ~/.hush/list/LIST_NAME/list.json - list data, in JSON + # ~/.hush/list/LIST_NAME/list.png - user-specified image for list return $self; } @@ -117,8 +122,10 @@ sub send_message { die "Max recipients of $MAX_RECIPIENTS exceeded" if (@$recipients > $MAX_RECIPIENTS); - # prevent an easily searchable single xtn amount - my $amount = 1e-4 + (1e-5*rand()); + # TODO: can we make amount=0 and have fee-only xtns? + # amount is hidden, so it does not identify list messages via metadata + my $amount = 1e-4; + my $fee = 1e-6; # this could blow up for a bajillion reasons... try {