shilling 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Manifest.txt +0 -1
- data/README.md +4 -2
- data/Rakefile +4 -2
- data/lib/shilling.rb +19 -3
- data/lib/shilling/bank.rb +1 -1
- data/lib/shilling/block.rb +1 -6
- data/lib/shilling/version.rb +1 -1
- data/lib/shilling/views/_ledger.erb +1 -1
- data/lib/shilling/views/_wallet.erb +1 -1
- metadata +19 -6
- data/lib/shilling/ledger.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec576692c34de7444a874bab09bc0e738f75fd6
|
4
|
+
data.tar.gz: 1885f770b43715813f7062820c217b5f76ef7e10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb9d7fbba7d30f7d179b0e57cd6ca74987bb99a48e6fdc4397e508a1eb1d4b71d62aa991a41eded7faa96de1ed78538ce33f9d04e817e8ffc4eeb84a4ee7ce35
|
7
|
+
data.tar.gz: 4d957daa158c18849f024f43abee289234c46b0bacbae50a8984725f3a6e560b16ea47374aea074b17e852559c86c57b73276392dc09529d9083e98cfc4be92f
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -6,12 +6,13 @@ w/ public distributed (hyper) ledger book on the blockchain peer-to-peer over HT
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
* home :: [github.com/
|
10
|
-
* bugs :: [github.com/
|
9
|
+
* home :: [github.com/bitshilling/bitshilling.tools](https://github.com/bitshilling/bitshilling.tools)
|
10
|
+
* bugs :: [github.com/bitshilling/bitshilling.tools/issues](https://github.com/bitshilling/bitshilling.tools/issues)
|
11
11
|
* gem :: [rubygems.org/gems/shilling](https://rubygems.org/gems/shilling)
|
12
12
|
* rdoc :: [rubydoc.info/gems/shilling](http://rubydoc.info/gems/shilling)
|
13
13
|
|
14
14
|
|
15
|
+
|
15
16
|
## Command Line
|
16
17
|
|
17
18
|
Use the `shilling` command line tool. Try:
|
@@ -77,6 +78,7 @@ source "https://rubygems.org"
|
|
77
78
|
gem 'sinatra'
|
78
79
|
gem 'sass'
|
79
80
|
gem 'blockchain-lite'
|
81
|
+
gem 'ledger-lite'
|
80
82
|
```
|
81
83
|
|
82
84
|
run
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ Hoe.spec 'shilling' do
|
|
8
8
|
self.summary = 'shilling (or schilling) on the blockchain! rock-solid alpine dollar from austria; print (mine) your own shillings; run your own federated shilling central bank nodes w/ public distributed (hyper) ledger book on the blockchain peer-to-peer over HTTP; revolutionize the world one block at a time with cryptos'
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
self.urls = ['https://github.com/
|
11
|
+
self.urls = ['https://github.com/bitshilling/bitshilling.tools']
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'ruby-talk@ruby-lang.org'
|
@@ -20,9 +20,11 @@ Hoe.spec 'shilling' do
|
|
20
20
|
self.extra_deps = [
|
21
21
|
['sinatra', '>=2.0'],
|
22
22
|
['sass'], ## used for css style preprocessing (scss)
|
23
|
-
['blockchain-lite', '>=1.
|
23
|
+
['blockchain-lite', '>=1.4.0'],
|
24
|
+
['ledger-lite', '>=1.1.1' ]
|
24
25
|
]
|
25
26
|
|
27
|
+
|
26
28
|
self.licenses = ['Public Domain']
|
27
29
|
|
28
30
|
self.spec_extras = {
|
data/lib/shilling.rb
CHANGED
@@ -12,8 +12,21 @@ require 'optparse' ## note: used for command line tool (see Tool in tool.rb)
|
|
12
12
|
### 3rd party gems
|
13
13
|
require 'sinatra/base' # note: use "modular" sinatra app / service
|
14
14
|
|
15
|
-
|
16
|
-
require 'blockchain-lite/
|
15
|
+
|
16
|
+
require 'blockchain-lite/base'
|
17
|
+
|
18
|
+
###
|
19
|
+
# add convenience top-level shortcut / alias
|
20
|
+
# "standard" default block for now block with proof of work
|
21
|
+
Block = BlockchainLite::ProofOfWork::Block
|
22
|
+
|
23
|
+
|
24
|
+
require 'ledger-lite/base'
|
25
|
+
|
26
|
+
###
|
27
|
+
# add convenience top-level shortcut / alias
|
28
|
+
Ledger = LedgerLite::Ledger
|
29
|
+
|
17
30
|
|
18
31
|
|
19
32
|
### our own code
|
@@ -24,7 +37,6 @@ require 'shilling/transaction'
|
|
24
37
|
require 'shilling/blockchain'
|
25
38
|
require 'shilling/pool'
|
26
39
|
require 'shilling/bank'
|
27
|
-
require 'shilling/ledger'
|
28
40
|
require 'shilling/wallet'
|
29
41
|
|
30
42
|
require 'shilling/node'
|
@@ -50,11 +62,15 @@ module Shilling
|
|
50
62
|
attr_accessor :mining_reward
|
51
63
|
|
52
64
|
## note: add a (†) coinbase marker
|
65
|
+
## fix: "sync" with ledger-lite config!!!!
|
66
|
+
COINBASE = ['Coinbase†']
|
67
|
+
=begin
|
53
68
|
COINBASE = ['Großglockner†', 'Wildspitze†', 'Großvenediger†',
|
54
69
|
'Hochfeiler†', 'Zuckerhütl†', 'Hochalmspitze†',
|
55
70
|
'Gr. Muntanitz†', 'Hoher Riffler†',
|
56
71
|
'Parseierspitze†', 'Hoher Dachstein†'
|
57
72
|
]
|
73
|
+
=end
|
58
74
|
|
59
75
|
|
60
76
|
def initialize
|
data/lib/shilling/bank.rb
CHANGED
@@ -50,7 +50,7 @@ class Bank
|
|
50
50
|
## (convenience) delegate for ledger
|
51
51
|
## todo/check: use address instead of wallet - why? why not?
|
52
52
|
## for now single address wallet (that is, wallet==address)
|
53
|
-
@ledger.
|
53
|
+
@ledger.sufficient?( wallet, amount )
|
54
54
|
end
|
55
55
|
|
56
56
|
|
data/lib/shilling/block.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
Block = BlockchainLite::ProofOfWork::Block
|
4
|
-
|
5
|
-
## see https://github.com/openblockchains/blockchain.lite.rb/blob/master/lib/blockchain-lite/proof_of_work/block.rb
|
6
|
-
|
7
2
|
######
|
8
3
|
## add more methods
|
9
4
|
|
10
|
-
class Block
|
11
5
|
|
6
|
+
class Block
|
12
7
|
|
13
8
|
def to_h
|
14
9
|
{ index: @index,
|
data/lib/shilling/version.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<h2>Address</h2>
|
5
5
|
<div><%= @node.wallet.address %></div>
|
6
6
|
<h2>Balance</h2>
|
7
|
-
<div class="balance">$<%= @node.bank.ledger
|
7
|
+
<div class="balance">$<%= @node.bank.ledger[@node.wallet.address] || 0 %></div>
|
8
8
|
</div>
|
9
9
|
<form action="/send" method="post" class="transaction-form">
|
10
10
|
<label for="to">To</label>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shilling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.4.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ledger-lite
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.1
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rdoc
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +119,6 @@ files:
|
|
105
119
|
- lib/shilling/block.rb
|
106
120
|
- lib/shilling/blockchain.rb
|
107
121
|
- lib/shilling/cache.rb
|
108
|
-
- lib/shilling/ledger.rb
|
109
122
|
- lib/shilling/node.rb
|
110
123
|
- lib/shilling/pool.rb
|
111
124
|
- lib/shilling/service.rb
|
@@ -120,7 +133,7 @@ files:
|
|
120
133
|
- lib/shilling/views/index.erb
|
121
134
|
- lib/shilling/views/style.scss
|
122
135
|
- lib/shilling/wallet.rb
|
123
|
-
homepage: https://github.com/
|
136
|
+
homepage: https://github.com/bitshilling/bitshilling.tools
|
124
137
|
licenses:
|
125
138
|
- Public Domain
|
126
139
|
metadata: {}
|
data/lib/shilling/ledger.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ledger
|
3
|
-
attr_reader :wallets ## use addresses - why? why not? for now single address wallet (wallet==address)
|
4
|
-
|
5
|
-
def initialize( chain=[] )
|
6
|
-
@wallets = {}
|
7
|
-
chain.each do |block|
|
8
|
-
apply_transactions( block.transactions )
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def sufficient_funds?( wallet, amount )
|
13
|
-
return true if Shilling.config.coinbase?( wallet )
|
14
|
-
@wallets.has_key?( wallet ) && @wallets[wallet] - amount >= 0
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def apply_transactions( transactions )
|
21
|
-
transactions.each do |tx|
|
22
|
-
if sufficient_funds?(tx.from, tx.amount)
|
23
|
-
@wallets[tx.from] -= tx.amount unless Shilling.config.coinbase?( tx.from )
|
24
|
-
@wallets[tx.to] ||= 0
|
25
|
-
@wallets[tx.to] += tx.amount
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end ## class Ledger
|