Browse Source

hushlists have a default chain, which can be changed at run-time to send to contact addresses on other chains

master
Jonathan "Duke" Leto 7 years ago
parent
commit
32d4169339
  1. 29
      bin/hushlist
  2. 20
      lib/Hush/List.pm

29
bin/hushlist

@ -23,10 +23,9 @@ print "Hushlist running on $blockchain ${chain}net, $blocks blocks\n";
print "Balances: transparent $tbalance HUSH, private $zbalance HUSH\n";
# we only need one
my $list = Hush::List->new;
my $command = shift || help();
my $COMMANDS = {
my $list = Hush::List->new;
my $command = shift || help();
my $COMMANDS = {
"add" => \&add,
"contact" => \&contact,
"new" => \&new,
@ -43,10 +42,22 @@ sub help {
sub contact {
my $cmd = shift || '';
if ($cmd eq 'new') {
# add a hush contact, yay
my ($name,$zaddr) = @ARGV;
die Dumper [ $name, $zaddr ];
my $subcommands = {
"add" => sub {
# add a hush contact, yay
my ($cmd,$name,$zaddr) = @ARGV;
barf Dumper [ $cmd, $name, $zaddr ];
},
"rm" => sub {
my ($cmd,$name,$zaddr) = @ARGV;
barf Dumper [ $cmd, $name, $zaddr ];
},
};
my $subcmd = $subcommands->{$cmd};
if ($subcmd) {
$subcmd->();
} else {
barf "Invalid hushlist contact subcommand!";
}
}
@ -69,7 +80,7 @@ sub new {
}
sub run {
print "Running command $command\n";
#print "Running command $command\n";
my $cmd = $COMMANDS->{$command};
if ($cmd) {

20
lib/Hush/List.pm

@ -96,6 +96,20 @@ sub global_status {
print "\t- $hushlist: " . scalar(@members) . " members \n";
}
}
print "Hushlist contacts:\n ";
# other possibilties: KMD, ZEN, others?
my @chains = qw/hush tush zec taz/;
for my $chain (@chains) {
my $contacts_file = catdir($HUSHLIST_CONFIG_DIR,"$chain-contacts.txt");
if (-e $contacts_file) {
my @contacts = read_file($contacts_file);
my $uchain = uc($chain);
print "\t- " . scalar(@contacts) . " $uchain contacts\n";
}
}
}
# show details about a particular hushlist
@ -142,6 +156,12 @@ sub new_list {
open my $fh, '>', $list_specific_conf or barf "Could not open $list_specific_conf for writing";
print $fh "# hushlist $name config v$Hush::List::VERSION\n";
print $fh "generated=$time\n";
# default chain is hush for now
# changing the chain of an existing list means that the subset
# of members that have addresses in the local contact list for the
# new chain will receive message, or operation aborts if no valid
# contacts on new chain
print $fh "chain=hush\n";
close $fh;
}

Loading…
Cancel
Save