-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
2,734 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
########### | ||
# cached / saved state / data | ||
|
||
data.json | ||
data.*.json | ||
|
||
|
||
|
||
########## | ||
# ignore Gemfile.lock for now | ||
|
||
Gemfile.lock | ||
|
||
|
||
#### | ||
# ignore sass cache | ||
.sass-cache | ||
|
||
|
||
|
||
*.gem | ||
*.rbc | ||
/.config | ||
/coverage/ | ||
/InstalledFiles | ||
/pkg/ | ||
/spec/reports/ | ||
/spec/examples.txt | ||
/test/tmp/ | ||
/test/version_tmp/ | ||
/tmp/ | ||
|
||
# Used by dotenv library to load environment variables. | ||
# .env | ||
|
||
## Specific to RubyMotion: | ||
.dat* | ||
.repl_history | ||
build/ | ||
*.bridgesupport | ||
build-iPhoneOS/ | ||
build-iPhoneSimulator/ | ||
|
||
## Specific to RubyMotion (use of CocoaPods): | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# vendor/Pods/ | ||
|
||
## Documentation cache and generated files: | ||
/.yardoc/ | ||
/_yardoc/ | ||
/doc/ | ||
/rdoc/ | ||
|
||
## Environment normalization: | ||
/.bundle/ | ||
/vendor/bundle | ||
/lib/bundler/man/ | ||
|
||
# for a library or gem, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# Gemfile.lock | ||
# .ruby-version | ||
# .ruby-gemset | ||
|
||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: | ||
.rvmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM ruby | ||
|
||
RUN mkdir /centralbank | ||
WORKDIR /centralbank | ||
COPY . /centralbank/ | ||
RUN bundle install --quiet | ||
EXPOSE 9292 | ||
CMD [ "rackup", "--host", "0.0.0.0", "-p", "9292"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Gemfile | ||
|
||
source "https://rubygems.org" | ||
|
||
gem 'sinatra' | ||
gem 'sass' | ||
gem 'blockchain-lite' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### 0.1.0 / 2017-12-14 | ||
|
||
* Everything is new. First release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
HISTORY.md | ||
LICENSE.md | ||
Manifest.txt | ||
README.md | ||
Rakefile | ||
bin/centralbank | ||
lib/centralbank.rb | ||
lib/centralbank/bank.rb | ||
lib/centralbank/block.rb | ||
lib/centralbank/blockchain.rb | ||
lib/centralbank/cache.rb | ||
lib/centralbank/ledger.rb | ||
lib/centralbank/node.rb | ||
lib/centralbank/pool.rb | ||
lib/centralbank/service.rb | ||
lib/centralbank/tool.rb | ||
lib/centralbank/transaction.rb | ||
lib/centralbank/version.rb | ||
lib/centralbank/views/_blockchain.erb | ||
lib/centralbank/views/_ledger.erb | ||
lib/centralbank/views/_peers.erb | ||
lib/centralbank/views/_pending_transactions.erb | ||
lib/centralbank/views/_wallet.erb | ||
lib/centralbank/views/index.erb | ||
lib/centralbank/views/style.scss | ||
lib/centralbank/wallet.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Notes | ||
|
||
|
||
## Todos | ||
|
||
- [ ] add favicon.png - why? why not? (see webservice gem) | ||
- [ ] add a Pool class (for pending transaction pool) !!!!! | ||
- [ ] add secure versions with signature e.g. SecureWallet, SecureTransaction, etc. | ||
|
||
``` | ||
Source: https://www.reddit.com/r/ruby/comments/7ly337/day_24_ruby_advent_calendar_2017_centralbank/ | ||
I'm playing with your Ruby blockchain stuff. It's very good. It's giving me a way to learn it without having to learn Go or C++ at the same time. But... | ||
When I try running central bank from the command line as described in blockchains section 6. using | ||
centralbank | ||
it doesn't work because centralbank is in the bin/ directory, so I tried (after setting chmod +x etc) | ||
bin/centralbank | ||
and then got an error I've never seen before | ||
env: ruby\r: No such file or directory | ||
So I wrote added one space at the end of the shebang header line That removed the extra \r and I then progressed to | ||
bin/centralbank | ||
Traceback (most recent call last): | ||
(LoadError)h file or directory -- | ||
Because it doesn't know where the library path is. If I run with | ||
ruby -Ilib bin/centralbank | ||
Then it's fine. | ||
So you need to do something to remove that \r at the end of the shebang line, and add the library path before the require. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# centralbank library / gem and command line tool | ||
|
||
print your own money / cryptocurrency; run your own federated central bank nodes on the blockchain peer-to-peer over HTTP; revolutionize the world one block at a time | ||
|
||
|
||
* home :: [github.com/openblockchains/centralbank](https://github.com/openblockchains/centralbank) | ||
* bugs :: [github.com/openblockchains/centralbank/issues](https://github.com/openblockchains/centralbank/issues) | ||
* gem :: [rubygems.org/gems/centralbank](https://rubygems.org/gems/centralbank) | ||
* rdoc :: [rubydoc.info/gems/centralbank](http://rubydoc.info/gems/centralbank) | ||
|
||
|
||
## Command Line | ||
|
||
Use the `centralbank` command line tool. Try: | ||
|
||
``` | ||
$ centralbank -h | ||
``` | ||
|
||
resulting in: | ||
|
||
``` | ||
Usage: centralbank [options] | ||
Wallet options: | ||
-n, --name=NAME Address name (default: Alice) | ||
Server (node) options: | ||
-o, --host HOST listen on HOST (default: 0.0.0.0) | ||
-p, --port PORT use PORT (default: 4567) | ||
-h, --help Prints this help | ||
``` | ||
|
||
To start a new (network) node using the default wallet | ||
address (that is, Alice) and the default server host and port settings | ||
use: | ||
|
||
``` | ||
$ centralbank | ||
``` | ||
|
||
Stand back ten feets :-) while starting up the machinery. | ||
Ready to print (mine) money on the blockchain? | ||
In your browser open up the page e.g. `http://localhost:4567`. Voila! | ||
|
||
 | ||
|
||
|
||
|
||
Note: You can start a second node on your computer - | ||
make sure to use a different port (use the `-p/--port` option) | ||
and (recommended) | ||
a different wallet address (use the `-n/--name` option). | ||
Example: | ||
|
||
``` | ||
$ centralbank -p 5678 -n Bob | ||
``` | ||
|
||
Happy mining! | ||
|
||
|
||
|
||
## Local Development Setup | ||
|
||
For local development - clone or download (and unzip) the centralbank code repo. | ||
Next install all dependencies using bundler with a Gemfile e.g.: | ||
|
||
``` ruby | ||
# Gemfile | ||
|
||
source "https://rubygems.org" | ||
|
||
gem 'sinatra' | ||
gem 'sass' | ||
gem 'blockchain-lite' | ||
``` | ||
|
||
run | ||
|
||
``` | ||
$ bundle ## will use the Gemfile (see above) | ||
``` | ||
|
||
and now you're ready to run your own centralbank server node. Use the [`config.ru`](config.ru) script for rack: | ||
|
||
``` ruby | ||
# config.ru | ||
|
||
$LOAD_PATH << './lib' | ||
|
||
require 'centralbank' | ||
|
||
run Centralbank::Service | ||
``` | ||
|
||
and startup the money printing machine using rackup - the rack command line tool: | ||
|
||
``` | ||
$ rackup ## will use the config.ru - rackup configuration script (see above). | ||
``` | ||
|
||
In your browser open up the page e.g. `http://localhost:9292`. Voila! Happy mining! | ||
|
||
|
||
|
||
|
||
## References | ||
|
||
[**Programming Cryptocurrencies and Blockchains (in Ruby)**](http://yukimotopress.github.io/blockchains) by Gerald Bauer et al, 2018, Yuki & Moto Press | ||
|
||
|
||
## License | ||
|
||
 | ||
|
||
The `centralbank` scripts are dedicated to the public domain. | ||
Use it as you please with no restrictions whatsoever. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'hoe' | ||
require './lib/centralbank/version.rb' | ||
|
||
Hoe.spec 'centralbank' do | ||
|
||
self.version = Centralbank::VERSION | ||
|
||
self.summary = 'centralbank - print your own money / cryptocurrency; run your own federated central bank nodes on the blockchain peer-to-peer over HTTP; revolutionize the world one block at a time' | ||
self.description = summary | ||
|
||
self.urls = ['https://github.com/openblockchains/centralbank'] | ||
|
||
self.author = 'Gerald Bauer' | ||
self.email = '[email protected]' | ||
|
||
# switch extension to .markdown for gihub formatting | ||
self.readme_file = 'README.md' | ||
self.history_file = 'History.md' | ||
|
||
self.extra_deps = [ | ||
['sinatra', '>=2.0'], | ||
['sass'], ## used for css style preprocessing (scss) | ||
['blockchain-lite', '>=1.3.1'], | ||
] | ||
|
||
self.licenses = ['Public Domain'] | ||
|
||
self.spec_extras = { | ||
required_ruby_version: '>= 2.3' | ||
} | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env ruby | ||
|
||
################### | ||
# == DEV TIPS: | ||
# | ||
# For local testing run like: | ||
# | ||
# ruby -Ilib bin/centralbank | ||
# | ||
# Set the executable bit in Linux. Example: | ||
# | ||
# % chmod a+x bin/centralbank | ||
# | ||
|
||
require 'centralbank' | ||
|
||
Centralbank.main |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### note: for local testing - add to load path ./lib | ||
## to test / run use: | ||
## $ rackup | ||
|
||
|
||
$LOAD_PATH << './lib' | ||
|
||
require 'centralbank' | ||
|
||
|
||
run Centralbank::Service |
Oops, something went wrong.