#!/usr/bin/env perl6

use v6;
use lib './lib';
use BlkMeV::Net;

sub MAIN ( Str $chain_name =  "bitcoin", Str $seed_host = "" ) {
  my $master_switch = Channel.new;
  my @mempool;
  my @clientpool;

  my $chain = BlkMeV::Chain::Chain.new(:name($chain_name));

  # clientpool supply
  my $client_supplier = Net::client_pool_builder(:@clientpool,
                                                 :@mempool,
                                                 :$master_switch);

  # seed the pool
  my $host = $seed_host.chars > 0 ?? $seed_host !! $chain.params.host;
  my %client = host => $host;
  $client_supplier.emit(($chain, %client, True));

  $master_switch.receive; # wait unit quit
  say "Shutting down";
}

=begin pod
=head1 USAGE
$ blkmev
=end pod

