Mojocoin::Faucet has been discontinued and kept here for historical reasons
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:
- bitcoind http://github.com/bitcoin/bitcoin
- Mojolicious http://mojolicio.us
- Redis http://redis.io
- Twitter Bootstrap http://twitter.github.com/bootstrap
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.
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:
- Continuum
- Continuum::BitcoinRPC
- Continuum::Redis
- anyevent-jsonrpc-perl This is a fork from AnyEvent::JSONRPC::HTTP::Client fixing a small issue with error handling in the HTTP client. We only use the HTTP client from this package.
- Mojocoin::Faucet (this project)
And at least the following modules from CPAN:
- Mojolicious
- AnyEvent
- EV (recommended event loop library)
- Mojo::Redis
- GD::Barcode
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:
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:
morbo script/mojocoin-faucet.pl -l http://127.0.0.1:3000
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.
Please report any bugs in the projects bug tracker:
http://github.com/plaprade/Mojocoin-Faucet/issues
You can also submit a patch.
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