Skip to content
This repository has been archived by the owner on Sep 10, 2018. It is now read-only.

plaprade/Mojocoin-Faucet

Repository files navigation

Mojocoin::Faucet has been discontinued and kept here for historical reasons

Mojocoin::Faucet - Bitcoin Faucet Implementation

Mojocoin::Faucet is a lightweight implementation of a Bitcoin faucet in Perl. It is built on top of the popular Mojolicious web framework and uses Redis as an in-memory key/value data store. Mojocoin::Faucet delegates most bitcoin-related tasks to the original Satoshi bitcoind client. We use bootstrap from twitter for CSS designs. Here is a wrap up of the technologies used:

Frameworks & Tools

Mojolicious is a cooperative multitasking web framework as it runs on a single-process event loop (usually EV). You can leverage the power of GNU/Linux pre-forking using the built-in Hypnotoad web server.

Mojolicious is an asynchronous web framework. The programming style is mostly callback-oriented. You install listeners on the event loop and provide callbacks for specifying your program continuations. This shouldn't been too alien if you have some javascript or node.js background.

To make asynchronous programming easier with Mojolicious, we designed the Continuum framework. It allows us to run asynchronous commands in parallel and provide merge-point callbacks very easily. This should be fairly simple to understand:

    use Continuum;
    use Continuum::BitcoinRPC # $bitcoin
    use Continuum::Redis # $redis
    

    $bitcoin->GetBalance
        ->merge( $bitcoin->ValidateAddress( $address ) )
        ->merge( $redis->hget( ip => value ) )
        ->then( sub { 
            my ( $balance, $validation, $ip ) = @_;
            # This callback is called once all 3 asynchronous
            # operations above are completed
        });

To communicate with the Satoshi Bitcoin implementation, I wrote Continuum::BitcoinRPC. It is a simple JSON/RPC interface to bitcoind.

Installation

Upgrade to Perl v5.14 if you haven't already. This program requires some features that are only well supported from that version.

You will need the following Perl modules from github:

And at least the following modules from CPAN:

You may be missing upstream dependencies from CPAN. Just install them as you go.

You'll need to install bitcoind and configure it to use RPC:

bitcoin.org

The Faucet needs some configuration settings in the file mojocoin-faucet.conf at the root directory of the application. Look at mojocoin-faucet.conf.example.

Finally, install Redis.io and make it available on the localhost interface, port 6379 (default port). If you change the Redis network settings, you'll need to update the Faucet.pm file.

To launch the server, use the following commands from the project root:

Development

morbo script/mojocoin-faucet.pl -l http://127.0.0.1:3000

Production (single process)

script/mojocoin-faucet.pl daemon -l http://*:80

You can use Hypnotoad for a prefork Unix-optimized server, Although it has not been tested with the faucet yet. The default Mojolicious server should be enough since the application is optimized for asynchronous IO.

Bugs

Please report any bugs in the projects bug tracker:

http://github.com/plaprade/Mojocoin-Faucet/issues

You can also submit a patch.

Contributing

We're glad you want to contribute! It's simple:

  • Fork Mojocoin::Faucet
  • Create a branch git checkout -b my_branch
  • Commit your changes git commit -am 'comments'
  • Push the branch git push origin my_branch
  • Open a pull request

About

Faucet web application for Bitcoin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages