Browse Source

Better error message when RPC server is down

master
Jonathan "Duke" Leto 7 years ago
parent
commit
bdf5a1f045
  1. 3
      bin/hushlist
  2. 4
      lib/Hush/List.pm
  3. 11
      lib/Hush/RPC.pm

3
bin/hushlist

@ -23,7 +23,8 @@ 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 $options = {};
my $list = Hush::List->new($rpc, $options);
my $command = shift || help();
my $COMMANDS = {
"add" => \&add,

4
lib/Hush/List.pm

@ -14,6 +14,7 @@ my $MAX_RECIPIENTS = 54;
my $HUSH_CONFIG_DIR = $ENV{HUSH_CONFIG_DIR} || catdir($ENV{HOME},'.hush');
my $HUSHLIST_CONFIG_DIR = $ENV{HUSH_CONFIG_DIR} || catdir($HUSH_CONFIG_DIR, 'list');
our $VERSION = 20171031;
my $rpc = Hush::RPC->new;
sub _sanity_checks {
@ -75,9 +76,8 @@ sub create_default_conf {
}
sub new {
my ($options) = @_;
my ($rpc,$options) = @_;
my $hush_list = {};
my $rpc = Hush::RPC->new($options);
# we only need a single RPC connection
$hush_list->{rpc} = $rpc;

11
lib/Hush/RPC.pm

@ -20,7 +20,16 @@ sub new {
if ($info) {
return $rpc,
} else {
barf "Unable to make RPC connection to $host:$port !";
my $coins = {
8822 => 'HUSH',
18822 => 'TUSH',
8232 => 'ZEC',
18232 => 'TAZ',
};
my $coin = $coins->{$port} || 'cryptocoin';
print "Unable to make RPC connection to $coin full node at $host:$port !\n";
print "Your $coin full node is not running, or not accessible at that port :(\n";
exit(1);
}
}

Loading…
Cancel
Save