blockchain-lite 1.1.0 → 1.4.1

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.
@@ -1,35 +1,93 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_block.rb
6
-
7
-
8
- require 'helper'
9
-
10
-
11
- class TestBlock < MiniTest::Test
12
-
13
- def test_version
14
- pp BlockchainLite.version
15
- pp BlockchainLite.banner
16
- pp BlockchainLite.root
17
-
18
- assert true ## (for now) everything ok if we get here
19
- end
20
-
21
- def test_example
22
-
23
- b0 = Block.first( 'Genesis' )
24
- b1 = Block.next( b0, 'Transaction Data...' )
25
- b2 = Block.next( b1, 'Transaction Data......' )
26
- b3 = Block.next( b2, 'More Transaction Data...' )
27
-
28
- blockchain = [b0, b1, b2, b3]
29
-
30
- pp blockchain
31
-
32
- assert true ## (for now) everything ok if we get here
33
- end
34
-
35
- end # class TestBlock
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_block.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestBlock < MiniTest::Test
12
+
13
+ include ProofOfWork ## adds Block = BlockchainLite::ProofOfWork::Block etc.
14
+
15
+
16
+ def test_example
17
+
18
+ b0 = Block.first( 'Genesis' )
19
+ b1 = Block.next( b0, 'Transaction Data...' )
20
+ b2 = Block.next( b1, 'Transaction Data...', 'Transaction Data...' )
21
+ b3 = Block.next( b2 ) ## no transaction data
22
+ b4 = Block.next( b3, ['Transaction Data...', 'Transaction Data...'] )
23
+
24
+ blockchain = [b0, b1, b2, b3, b4]
25
+
26
+ pp blockchain
27
+
28
+ assert true ## (for now) everything ok if we get here
29
+ end
30
+
31
+ def test_tulips_example
32
+ b0 = Block.first(
33
+ { from: "Dutchgrown", to: "Vincent", name: "Tulip Bloemendaal Sunset", qty: 10 },
34
+ { from: "Keukenhof", to: "Anne", name: "Tulip Semper Augustus", qty: 7 } )
35
+
36
+ b1 = Block.next( b0,
37
+ { from: "Flowers", to: "Ruben", name: "Tulip Admiral van Eijck", qty: 5 },
38
+ { from: "Vicent", to: "Anne", name: "Tulip Bloemendaal Sunset", qty: 3 },
39
+ { from: "Anne", to: "Julia", name: "Tulip Semper Augustus", qty: 1 },
40
+ { from: "Julia", to: "Luuk", name: "Tulip Semper Augustus", qty: 1 } )
41
+
42
+ b2 = Block.next( b1,
43
+ { from: "Bloom & Blossom", to: "Daisy", name: "Tulip Admiral of Admirals", qty: 8 },
44
+ { from: "Vincent", to: "Max", name: "Tulip Bloemendaal Sunset", qty: 2 },
45
+ { from: "Anne", to: "Martijn", name: "Tulip Semper Augustus", qty: 2 },
46
+ { from: "Ruben", to: "Julia", name: "Tulip Admiral van Eijck", qty: 2 } )
47
+
48
+ blockchain = [b0, b1, b2]
49
+
50
+ pp blockchain
51
+
52
+ assert true ## (for now) everything ok if we get here
53
+ end
54
+
55
+
56
+ def timestamp1637
57
+ ## change year to 1637 :-)
58
+ ## note: time (uses signed integer e.g. epoch/unix time starting in 1970 with 0)
59
+ ## todo: add nano/mili-seconds - why? why not? possible?
60
+ now = Time.now.utc.to_datetime
61
+ past = DateTime.new( 1637, now.month, now.mday, now.hour, now.min, now.sec, now.zone )
62
+ past
63
+ end
64
+
65
+ def test_tulips_1637_example
66
+
67
+ b0 = Block.first(
68
+ { from: "Dutchgrown", to: "Vincent", name: "Tulip Bloemendaal Sunset", qty: 10 },
69
+ { from: "Keukenhof", to: "Anne", name: "Tulip Semper Augustus", qty: 7 },
70
+ timestamp: timestamp1637 )
71
+
72
+ b1 = Block.next( b0,
73
+ { from: "Flowers", to: "Ruben", name: "Tulip Admiral van Eijck", qty: 5 },
74
+ { from: "Vicent", to: "Anne", name: "Tulip Bloemendaal Sunset", qty: 3 },
75
+ { from: "Anne", to: "Julia", name: "Tulip Semper Augustus", qty: 1 },
76
+ { from: "Julia", to: "Luuk", name: "Tulip Semper Augustus", qty: 1 },
77
+ timestamp: timestamp1637 )
78
+
79
+ b2 = Block.next( b1,
80
+ { from: "Bloom & Blossom", to: "Daisy", name: "Tulip Admiral of Admirals", qty: 8 },
81
+ { from: "Vincent", to: "Max", name: "Tulip Bloemendaal Sunset", qty: 2 },
82
+ { from: "Anne", to: "Martijn", name: "Tulip Semper Augustus", qty: 2 },
83
+ { from: "Ruben", to: "Julia", name: "Tulip Admiral van Eijck", qty: 2 },
84
+ timestamp: timestamp1637 )
85
+
86
+ blockchain = [b0, b1, b2]
87
+
88
+ pp blockchain
89
+
90
+ assert true ## (for now) everything ok if we get here
91
+ end
92
+
93
+ end # class TestBlock
@@ -10,16 +10,18 @@ require 'helper'
10
10
 
11
11
  class TestBlockBasic < MiniTest::Test
12
12
 
13
- def test_example
13
+ include Basic ## adds Block = BlockchainLite::Basic::Block etc.
14
+
14
15
 
15
- block_class = BlockchainLite::Basic::Block
16
+ def test_example
16
17
 
17
- b0 = block_class.first( 'Genesis' )
18
- b1 = block_class.next( b0, 'Transaction Data...' )
19
- b2 = block_class.next( b1, 'Transaction Data......' )
20
- b3 = block_class.next( b2, 'More Transaction Data...' )
18
+ b0 = Block.first( 'Genesis' )
19
+ b1 = Block.next( b0, 'Transaction Data...' )
20
+ b2 = Block.next( b1, 'Transaction Data...', 'Transaction Data...' )
21
+ b3 = Block.next( b2 ) ## no transaction data
22
+ b4 = Block.next( b3, ['Transaction Data...', 'Transaction Data...'] )
21
23
 
22
- blockchain = [b0, b1, b2, b3]
24
+ blockchain = [b0, b1, b2, b3, b4]
23
25
 
24
26
  pp blockchain
25
27
 
@@ -10,16 +10,18 @@ require 'helper'
10
10
 
11
11
  class TestBlockProofOfWork < MiniTest::Test
12
12
 
13
- def test_example
13
+ include ProofOfWork ## adds Block = BlockchainLite::ProofOfWork::Block etc.
14
+
14
15
 
15
- block_class = BlockchainLite::ProofOfWork::Block
16
+ def test_example
16
17
 
17
- b0 = block_class.first( 'Genesis' )
18
- b1 = block_class.next( b0, 'Transaction Data...' )
19
- b2 = block_class.next( b1, 'Transaction Data......' )
20
- b3 = block_class.next( b2, 'More Transaction Data...' )
18
+ b0 = Block.first( 'Genesis' )
19
+ b1 = Block.next( b0, 'Transaction Data...' )
20
+ b2 = Block.next( b1, 'Transaction Data...', 'Transaction Data...' )
21
+ b3 = Block.next( b2 ) ## no transaction data
22
+ b4 = Block.next( b3, ['Transaction Data...', 'Transaction Data...'] )
21
23
 
22
- blockchain = [b0, b1, b2, b3]
24
+ blockchain = [b0, b1, b2, b3, b4]
23
25
 
24
26
  pp blockchain
25
27
 
@@ -9,30 +9,27 @@ require 'helper'
9
9
 
10
10
  class TestBlockchain < MiniTest::Test
11
11
 
12
+ include ProofOfWork ## adds:
13
+ ## Block = BlockchainLite::ProofOfWork::Block etc.
14
+ ## class Blockchain < BlockchainLite::Blockchain
15
+ ## def block_class() Block; end
16
+ ## end
17
+
18
+
12
19
  def test_new
13
20
 
14
21
  b = Blockchain.new
15
22
 
23
+ b << 'Genesis'
16
24
  b << 'Transaction Data...'
25
+ b << ['Transaction Data...']
26
+ b << ['Transaction Data...', 'Transaction Data...']
27
+ b << [] ## empty block (no transactions)
17
28
 
18
29
  ## add do-it-yourself built block
19
- b << Block.next( b.last, 'Transaction Data......' )
20
-
21
- b << 'More Transaction Data...'
22
-
23
- pp b
24
-
25
- assert true ## (for now) everything ok if we get here
26
- end
27
-
28
-
29
- def test_with_block_class
30
-
31
- b = Blockchain.new( block_class: BlockchainLite::Basic::Block )
30
+ b << Block.next( b.last, 'Transaction Data...' )
32
31
 
33
32
  b << 'Transaction Data...'
34
- b << 'Transaction Data......'
35
- b << 'More Transaction Data...'
36
33
 
37
34
  pp b
38
35
 
@@ -44,8 +41,8 @@ def test_wrap
44
41
 
45
42
  b0 = Block.first( 'Genesis' )
46
43
  b1 = Block.next( b0, 'Transaction Data...' )
47
- b2 = Block.next( b1, 'Transaction Data......' )
48
- b3 = Block.next( b2, 'More Transaction Data...' )
44
+ b2 = Block.next( b1, 'Transaction Data...' )
45
+ b3 = Block.next( b2, 'Transaction Data...' )
49
46
  blockchain = [b0, b1, b2, b3]
50
47
 
51
48
  b = Blockchain.new( blockchain )
@@ -58,7 +55,10 @@ def test_wrap
58
55
  assert_equal true, b.valid?
59
56
 
60
57
  ## corrupt data in block in chain
61
- b2.instance_eval %{ @data='XXXXXXX' }
58
+ b2.instance_eval <<RUBY
59
+ @transactions = ['xxxxxx']
60
+ @transactions_hash = MerkleTree.compute_root_for( @transactions )
61
+ RUBY
62
62
 
63
63
  assert_equal true, b.broken?
64
64
  assert_equal false, b.valid?
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_version.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestVersion < MiniTest::Test
12
+
13
+ def test_version
14
+ pp BlockchainLite.version
15
+ pp BlockchainLite.banner
16
+ pp BlockchainLite.root
17
+
18
+ assert true ## (for now) everything ok if we get here
19
+ end
20
+
21
+ end # class TestVersion
metadata CHANGED
@@ -1,63 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blockchain-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-23 00:00:00.000000000 Z
11
+ date: 2021-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: merkletree
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rdoc
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - "~>"
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '4.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '7'
20
37
  type: :development
21
38
  prerelease: false
22
39
  version_requirements: !ruby/object:Gem::Requirement
23
40
  requirements:
24
- - - "~>"
41
+ - - ">="
25
42
  - !ruby/object:Gem::Version
26
43
  version: '4.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '7'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: hoe
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: '3.16'
53
+ version: '3.22'
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
58
  - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: '3.16'
60
+ version: '3.22'
41
61
  description: blockchain-lite - build your own blockchain with crypto hashes - revolutionize
42
62
  the world with blockchains, blockchains, blockchains one block at a time
43
63
  email: wwwmake@googlegroups.com
44
64
  executables: []
45
65
  extensions: []
46
66
  extra_rdoc_files:
47
- - HISTORY.md
48
- - LICENSE.md
67
+ - CHANGELOG.md
49
68
  - Manifest.txt
50
69
  - README.md
51
70
  files:
52
- - HISTORY.md
53
- - LICENSE.md
71
+ - CHANGELOG.md
54
72
  - Manifest.txt
55
73
  - README.md
56
74
  - Rakefile
57
75
  - lib/blockchain-lite.rb
76
+ - lib/blockchain-lite/base.rb
58
77
  - lib/blockchain-lite/basic/block.rb
59
78
  - lib/blockchain-lite/bitcoin/block.rb
60
- - lib/blockchain-lite/block.rb
61
79
  - lib/blockchain-lite/blockchain.rb
62
80
  - lib/blockchain-lite/proof_of_work/block.rb
63
81
  - lib/blockchain-lite/version.rb
@@ -66,11 +84,12 @@ files:
66
84
  - test/test_block_basic.rb
67
85
  - test/test_block_proof_of_work.rb
68
86
  - test/test_blockchain.rb
69
- homepage: https://github.com/openblockchains/blockchain.lite.rb
87
+ - test/test_version.rb
88
+ homepage: https://github.com/rubycoco/blockchain
70
89
  licenses:
71
90
  - Public Domain
72
91
  metadata: {}
73
- post_install_message:
92
+ post_install_message:
74
93
  rdoc_options:
75
94
  - "--main"
76
95
  - README.md
@@ -87,9 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
106
  - !ruby/object:Gem::Version
88
107
  version: '0'
89
108
  requirements: []
90
- rubyforge_project:
91
- rubygems_version: 2.5.2
92
- signing_key:
109
+ rubygems_version: 3.1.4
110
+ signing_key:
93
111
  specification_version: 4
94
112
  summary: blockchain-lite - build your own blockchain with crypto hashes - revolutionize
95
113
  the world with blockchains, blockchains, blockchains one block at a time
data/LICENSE.md DELETED
@@ -1,116 +0,0 @@
1
- CC0 1.0 Universal
2
-
3
- Statement of Purpose
4
-
5
- The laws of most jurisdictions throughout the world automatically confer
6
- exclusive Copyright and Related Rights (defined below) upon the creator and
7
- subsequent owner(s) (each and all, an "owner") of an original work of
8
- authorship and/or a database (each, a "Work").
9
-
10
- Certain owners wish to permanently relinquish those rights to a Work for the
11
- purpose of contributing to a commons of creative, cultural and scientific
12
- works ("Commons") that the public can reliably and without fear of later
13
- claims of infringement build upon, modify, incorporate in other works, reuse
14
- and redistribute as freely as possible in any form whatsoever and for any
15
- purposes, including without limitation commercial purposes. These owners may
16
- contribute to the Commons to promote the ideal of a free culture and the
17
- further production of creative, cultural and scientific works, or to gain
18
- reputation or greater distribution for their Work in part through the use and
19
- efforts of others.
20
-
21
- For these and/or other purposes and motivations, and without any expectation
22
- of additional consideration or compensation, the person associating CC0 with a
23
- Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
- and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
- and publicly distribute the Work under its terms, with knowledge of his or her
26
- Copyright and Related Rights in the Work and the meaning and intended legal
27
- effect of CC0 on those rights.
28
-
29
- 1. Copyright and Related Rights. A Work made available under CC0 may be
30
- protected by copyright and related or neighboring rights ("Copyright and
31
- Related Rights"). Copyright and Related Rights include, but are not limited
32
- to, the following:
33
-
34
- i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
- and translate a Work;
36
-
37
- ii. moral rights retained by the original author(s) and/or performer(s);
38
-
39
- iii. publicity and privacy rights pertaining to a person's image or likeness
40
- depicted in a Work;
41
-
42
- iv. rights protecting against unfair competition in regards to a Work,
43
- subject to the limitations in paragraph 4(a), below;
44
-
45
- v. rights protecting the extraction, dissemination, use and reuse of data in
46
- a Work;
47
-
48
- vi. database rights (such as those arising under Directive 96/9/EC of the
49
- European Parliament and of the Council of 11 March 1996 on the legal
50
- protection of databases, and under any national implementation thereof,
51
- including any amended or successor version of such directive); and
52
-
53
- vii. other similar, equivalent or corresponding rights throughout the world
54
- based on applicable law or treaty, and any national implementations thereof.
55
-
56
- 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
- applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
- unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
- and Related Rights and associated claims and causes of action, whether now
60
- known or unknown (including existing as well as future claims and causes of
61
- action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
- duration provided by applicable law or treaty (including future time
63
- extensions), (iii) in any current or future medium and for any number of
64
- copies, and (iv) for any purpose whatsoever, including without limitation
65
- commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
- the Waiver for the benefit of each member of the public at large and to the
67
- detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
- shall not be subject to revocation, rescission, cancellation, termination, or
69
- any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
- by the public as contemplated by Affirmer's express Statement of Purpose.
71
-
72
- 3. Public License Fallback. Should any part of the Waiver for any reason be
73
- judged legally invalid or ineffective under applicable law, then the Waiver
74
- shall be preserved to the maximum extent permitted taking into account
75
- Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
- is so judged Affirmer hereby grants to each affected person a royalty-free,
77
- non transferable, non sublicensable, non exclusive, irrevocable and
78
- unconditional license to exercise Affirmer's Copyright and Related Rights in
79
- the Work (i) in all territories worldwide, (ii) for the maximum duration
80
- provided by applicable law or treaty (including future time extensions), (iii)
81
- in any current or future medium and for any number of copies, and (iv) for any
82
- purpose whatsoever, including without limitation commercial, advertising or
83
- promotional purposes (the "License"). The License shall be deemed effective as
84
- of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
- License for any reason be judged legally invalid or ineffective under
86
- applicable law, such partial invalidity or ineffectiveness shall not
87
- invalidate the remainder of the License, and in such case Affirmer hereby
88
- affirms that he or she will not (i) exercise any of his or her remaining
89
- Copyright and Related Rights in the Work or (ii) assert any associated claims
90
- and causes of action with respect to the Work, in either case contrary to
91
- Affirmer's express Statement of Purpose.
92
-
93
- 4. Limitations and Disclaimers.
94
-
95
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
- surrendered, licensed or otherwise affected by this document.
97
-
98
- b. Affirmer offers the Work as-is and makes no representations or warranties
99
- of any kind concerning the Work, express, implied, statutory or otherwise,
100
- including without limitation warranties of title, merchantability, fitness
101
- for a particular purpose, non infringement, or the absence of latent or
102
- other defects, accuracy, or the present or absence of errors, whether or not
103
- discoverable, all to the greatest extent permissible under applicable law.
104
-
105
- c. Affirmer disclaims responsibility for clearing rights of other persons
106
- that may apply to the Work or any use thereof, including without limitation
107
- any person's Copyright and Related Rights in the Work. Further, Affirmer
108
- disclaims responsibility for obtaining any necessary consents, permissions
109
- or other rights required for any use of the Work.
110
-
111
- d. Affirmer understands and acknowledges that Creative Commons is not a
112
- party to this document and has no duty or obligation with respect to this
113
- CC0 or use of the Work.
114
-
115
- For more information, please see
116
- <http://creativecommons.org/publicdomain/zero/1.0/>