Perl6 HON - Decentralized Justice - Deep Study of Blockchain Code - This effort resulted in this Module

in blockchain •  5 months ago

So, today we are going to see a way to parse in the results from a DNS seed

This effort is being carried out in our project called HON. HON is a cryptocurrency which will be used to incentivize dispute resolutions in a decentralized way through the development of an Escrow Blockchain fully written in Perl6. More info to come...

hon-1.png

Here's the module we wrote

unit package EC::Grammars:auth<github:bioduds>;

# EC Grammars
## AUTHOR: EDUARDO CAPANEMA (bioduds@gmail.com)
## Licensed under GNU General Public License - full license at the end of file
## __NOTE FROM AUTHOR: We believe and support Software Livre

=begin SYNOPSIS
=begin code
    use EC::Grammars::DIG;
    my $proc = run 'dig', URL_YOU_WANT_TO_DIG_HERE, :out, :err;
    with $proc.out { say "Error running dig"; die; }
    my $output = $proc.out.slurp: :close;
    my $dig = EC::Grammars::DIG.new.parse( $output, :actions( EC:Grammars::DIG::Actions.new ) );
    say $dig<DATE>; ## you may here query which ever tokens or rules desired
    ## TO ITERATE USE, FOR INSTANCE:
    for $dig<ANSWER> -> $answers {
      say $answers<IP>; ## for instance
    }
=end code
=end SYNOPSIS

grammar DIG {
  rule TOP {
    ^^ '; ' <ANGLES> <DIG> <TITLE> <ANGLES> <URL>
    ';; global options: ' <GLOBAL_OPTIONS>
    ';; Got answer:'
    ';; ->>HEADER<<- opcode: ' <OPCODE> ', status: ' <STATUS> ', id:' <ID>
    ';; flags: ' \S+ \S+ \S+ '; QUERY: ' \d+', ANSWER: ' \d+ ', AUTHORITY: ' \d+', ADDITIONAL: ' \d+
    ';; OPT PSEUDOSECTION:'
    '; EDNS: version: ' \d+ ', flags:' \S* '; udp: ' \d+
    ';; QUESTION SECTION:'
    ';' <URL2> <IN> <RECORD>
    ';; ANSWER SECTION:'
    <ANSWER>+
    ';; Query time: ' \d+ 'msec'
    ';; SERVER: ' <S-IP>
    ';; WHEN: ' <DATE>
    ';; MSG SIZE  rcvd: ' \d+
  }
  token ANGLES { '<<>>' }
  token DIG { 'DiG' }
  token TITLE { \S+ }
  token URL { \S+ }
  token URL2 { \H+ }
  token GLOBAL_OPTIONS { \S+ }
  token OPCODE { <alnum>+ }
  token STATUS { <alnum>+ }
  token ID { \d+ }
  token IN { <alnum>+ }
  token RECORD { <alnum>+ }
  token PORT { \d+ }
  token IP { \d+ \. \d+ \. \d+ \. \d+ }
  rule ANSWER { <URL2> <PORT> <IN> <RECORD> <IP> }
  token S-IP{ <IP> '#' \d+ '(' <IP> ')' }
  token WEEK-DAY { \S+ }
  token MONTH { \S+ }
  token DAY { \d+ }
  token TIME { \d+ ':' \d+ ':' \d+ }
  token PLACE { \S+ }
  token YEAR { \d+ }
  rule DATE { <WEEK-DAY> <MONTH> <DAY> <TIME> <PLACE> <YEAR> }
}

class DIG::Actions {
  method TOP ($/) { return $/; }
}


#`{

GNU GENERAL PUBLIC LICENSE
   Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

}

Please, don't forget to UPVOTE and/or SUBSCRIBE

Cheers,


EDUARDO CAPANEMA
@bitworkers

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  trending

SUPERB POST ANON LIKE AN IDEA!

·

Thank you so much for you words @mfg
Cheers!
@bitworkers

Não tenho a menor ideia do que esse código significa, mas qualquer trabalho para descentralização da justiça ganha meu upvote!

·

:D Obrigado, @akro
É um imenso esforço construir uma blockchain do zero como NEM e deCRED e outras. É um projeto imenso. Estamos abertos a todo e qualquer esforço e ajuda. Junte-se a nós.
Abs,
Eduardo
@bitworkers

Boa Eduardo, vamos avante! bitworkers!

·

É isso aí, @elohimbrasil AVANTE!!
Abraços
@bitworkers

is the project host at github ?