Skip to content

Commit b9c8170

Browse files
committed
up
1 parent 9d0c001 commit b9c8170

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2734
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Gems:
88
- [p2p](p2p) - build your own peer-to-peer (p2p) networks; run your own peer-to-peer (p2p) nodes over HTTP
99

1010

11+
<!-- break -->
12+
13+
- [centralbank](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
14+
- [tulipmania](tulipmania) - tulips on the blockchain; learn by example from the real world (anno 1637) - buy! sell! hodl! enjoy the beauty of admiral of admirals, semper augustus, and more; run your own hyper ledger tulip exchange nodes on the blockchain peer-to-peer over HTTP; revolutionize the world one block at a time
1115

1216

1317

centralbank/.gitignore

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
###########
2+
# cached / saved state / data
3+
4+
data.json
5+
data.*.json
6+
7+
8+
9+
##########
10+
# ignore Gemfile.lock for now
11+
12+
Gemfile.lock
13+
14+
15+
####
16+
# ignore sass cache
17+
.sass-cache
18+
19+
20+
21+
*.gem
22+
*.rbc
23+
/.config
24+
/coverage/
25+
/InstalledFiles
26+
/pkg/
27+
/spec/reports/
28+
/spec/examples.txt
29+
/test/tmp/
30+
/test/version_tmp/
31+
/tmp/
32+
33+
# Used by dotenv library to load environment variables.
34+
# .env
35+
36+
## Specific to RubyMotion:
37+
.dat*
38+
.repl_history
39+
build/
40+
*.bridgesupport
41+
build-iPhoneOS/
42+
build-iPhoneSimulator/
43+
44+
## Specific to RubyMotion (use of CocoaPods):
45+
#
46+
# We recommend against adding the Pods directory to your .gitignore. However
47+
# you should judge for yourself, the pros and cons are mentioned at:
48+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
49+
#
50+
# vendor/Pods/
51+
52+
## Documentation cache and generated files:
53+
/.yardoc/
54+
/_yardoc/
55+
/doc/
56+
/rdoc/
57+
58+
## Environment normalization:
59+
/.bundle/
60+
/vendor/bundle
61+
/lib/bundler/man/
62+
63+
# for a library or gem, you might want to ignore these files since the code is
64+
# intended to run in multiple environments; otherwise, check them in:
65+
# Gemfile.lock
66+
# .ruby-version
67+
# .ruby-gemset
68+
69+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
70+
.rvmrc

centralbank/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ruby
2+
3+
RUN mkdir /centralbank
4+
WORKDIR /centralbank
5+
COPY . /centralbank/
6+
RUN bundle install --quiet
7+
EXPOSE 9292
8+
CMD [ "rackup", "--host", "0.0.0.0", "-p", "9292"]
9+

centralbank/Gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Gemfile
2+
3+
source "https://rubygems.org"
4+
5+
gem 'sinatra'
6+
gem 'sass'
7+
gem 'blockchain-lite'

centralbank/HISTORY.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### 0.1.0 / 2017-12-14
2+
3+
* Everything is new. First release.

centralbank/Manifest.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
HISTORY.md
2+
LICENSE.md
3+
Manifest.txt
4+
README.md
5+
Rakefile
6+
bin/centralbank
7+
lib/centralbank.rb
8+
lib/centralbank/bank.rb
9+
lib/centralbank/block.rb
10+
lib/centralbank/blockchain.rb
11+
lib/centralbank/cache.rb
12+
lib/centralbank/ledger.rb
13+
lib/centralbank/node.rb
14+
lib/centralbank/pool.rb
15+
lib/centralbank/service.rb
16+
lib/centralbank/tool.rb
17+
lib/centralbank/transaction.rb
18+
lib/centralbank/version.rb
19+
lib/centralbank/views/_blockchain.erb
20+
lib/centralbank/views/_ledger.erb
21+
lib/centralbank/views/_peers.erb
22+
lib/centralbank/views/_pending_transactions.erb
23+
lib/centralbank/views/_wallet.erb
24+
lib/centralbank/views/index.erb
25+
lib/centralbank/views/style.scss
26+
lib/centralbank/wallet.rb

centralbank/NOTES.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Notes
2+
3+
4+
## Todos
5+
6+
- [ ] add favicon.png - why? why not? (see webservice gem)
7+
- [ ] add a Pool class (for pending transaction pool) !!!!!
8+
- [ ] add secure versions with signature e.g. SecureWallet, SecureTransaction, etc.
9+
10+
```
11+
Source: https://www.reddit.com/r/ruby/comments/7ly337/day_24_ruby_advent_calendar_2017_centralbank/
12+
13+
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...
14+
15+
When I try running central bank from the command line as described in blockchains section 6. using
16+
17+
centralbank
18+
it doesn't work because centralbank is in the bin/ directory, so I tried (after setting chmod +x etc)
19+
20+
bin/centralbank
21+
and then got an error I've never seen before
22+
23+
env: ruby\r: No such file or directory
24+
So I wrote added one space at the end of the shebang header line That removed the extra \r and I then progressed to
25+
26+
bin/centralbank
27+
Traceback (most recent call last):
28+
(LoadError)h file or directory --
29+
Because it doesn't know where the library path is. If I run with
30+
31+
ruby -Ilib bin/centralbank
32+
Then it's fine.
33+
34+
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.
35+
```

centralbank/README.md

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# centralbank library / gem and command line tool
2+
3+
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
4+
5+
6+
* home :: [github.com/openblockchains/centralbank](https://github.com/openblockchains/centralbank)
7+
* bugs :: [github.com/openblockchains/centralbank/issues](https://github.com/openblockchains/centralbank/issues)
8+
* gem :: [rubygems.org/gems/centralbank](https://rubygems.org/gems/centralbank)
9+
* rdoc :: [rubydoc.info/gems/centralbank](http://rubydoc.info/gems/centralbank)
10+
11+
12+
## Command Line
13+
14+
Use the `centralbank` command line tool. Try:
15+
16+
```
17+
$ centralbank -h
18+
```
19+
20+
resulting in:
21+
22+
```
23+
Usage: centralbank [options]
24+
25+
Wallet options:
26+
-n, --name=NAME Address name (default: Alice)
27+
28+
Server (node) options:
29+
-o, --host HOST listen on HOST (default: 0.0.0.0)
30+
-p, --port PORT use PORT (default: 4567)
31+
-h, --help Prints this help
32+
```
33+
34+
To start a new (network) node using the default wallet
35+
address (that is, Alice) and the default server host and port settings
36+
use:
37+
38+
```
39+
$ centralbank
40+
```
41+
42+
Stand back ten feets :-) while starting up the machinery.
43+
Ready to print (mine) money on the blockchain?
44+
In your browser open up the page e.g. `http://localhost:4567`. Voila!
45+
46+
![](centralbank.png)
47+
48+
49+
50+
Note: You can start a second node on your computer -
51+
make sure to use a different port (use the `-p/--port` option)
52+
and (recommended)
53+
a different wallet address (use the `-n/--name` option).
54+
Example:
55+
56+
```
57+
$ centralbank -p 5678 -n Bob
58+
```
59+
60+
Happy mining!
61+
62+
63+
64+
## Local Development Setup
65+
66+
For local development - clone or download (and unzip) the centralbank code repo.
67+
Next install all dependencies using bundler with a Gemfile e.g.:
68+
69+
``` ruby
70+
# Gemfile
71+
72+
source "https://rubygems.org"
73+
74+
gem 'sinatra'
75+
gem 'sass'
76+
gem 'blockchain-lite'
77+
```
78+
79+
run
80+
81+
```
82+
$ bundle ## will use the Gemfile (see above)
83+
```
84+
85+
and now you're ready to run your own centralbank server node. Use the [`config.ru`](config.ru) script for rack:
86+
87+
``` ruby
88+
# config.ru
89+
90+
$LOAD_PATH << './lib'
91+
92+
require 'centralbank'
93+
94+
run Centralbank::Service
95+
```
96+
97+
and startup the money printing machine using rackup - the rack command line tool:
98+
99+
```
100+
$ rackup ## will use the config.ru - rackup configuration script (see above).
101+
```
102+
103+
In your browser open up the page e.g. `http://localhost:9292`. Voila! Happy mining!
104+
105+
106+
107+
108+
## References
109+
110+
[**Programming Cryptocurrencies and Blockchains (in Ruby)**](http://yukimotopress.github.io/blockchains) by Gerald Bauer et al, 2018, Yuki & Moto Press
111+
112+
113+
## License
114+
115+
![](https://publicdomainworks.github.io/buttons/zero88x31.png)
116+
117+
The `centralbank` scripts are dedicated to the public domain.
118+
Use it as you please with no restrictions whatsoever.

centralbank/Rakefile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'hoe'
2+
require './lib/centralbank/version.rb'
3+
4+
Hoe.spec 'centralbank' do
5+
6+
self.version = Centralbank::VERSION
7+
8+
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'
9+
self.description = summary
10+
11+
self.urls = ['https://github.com/openblockchains/centralbank']
12+
13+
self.author = 'Gerald Bauer'
14+
self.email = '[email protected]'
15+
16+
# switch extension to .markdown for gihub formatting
17+
self.readme_file = 'README.md'
18+
self.history_file = 'History.md'
19+
20+
self.extra_deps = [
21+
['sinatra', '>=2.0'],
22+
['sass'], ## used for css style preprocessing (scss)
23+
['blockchain-lite', '>=1.3.1'],
24+
]
25+
26+
self.licenses = ['Public Domain']
27+
28+
self.spec_extras = {
29+
required_ruby_version: '>= 2.3'
30+
}
31+
32+
end

centralbank/bin/centralbank

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env ruby
2+
3+
###################
4+
# == DEV TIPS:
5+
#
6+
# For local testing run like:
7+
#
8+
# ruby -Ilib bin/centralbank
9+
#
10+
# Set the executable bit in Linux. Example:
11+
#
12+
# % chmod a+x bin/centralbank
13+
#
14+
15+
require 'centralbank'
16+
17+
Centralbank.main

centralbank/centralbank.png

76 KB
Loading

centralbank/config.ru

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### note: for local testing - add to load path ./lib
2+
## to test / run use:
3+
## $ rackup
4+
5+
6+
$LOAD_PATH << './lib'
7+
8+
require 'centralbank'
9+
10+
11+
run Centralbank::Service

0 commit comments

Comments
 (0)