zold 0.26.17 → 0.26.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0649d6ccb04536eabe73074ef91e87317c15f35b64aea31739e8b82d4bb5347
4
- data.tar.gz: 788a6dfd9cb3a6cc687f1abe29a9636d3d3245e7e745481fdab8ebe7c96de753
3
+ metadata.gz: 89109464b2af91b04867b407d157ad720d3f427f448c219d35fb582a50b11d26
4
+ data.tar.gz: 8b5ec196c38cb866499d6b8668f78103d2d420195269a6420d8ef1fa91677d69
5
5
  SHA512:
6
- metadata.gz: dc2b1ad12503d024a5a31600186a7084b6def9d978fd4e531037f38d5d6e12160c2b47cd716adc89f02f474b4af52dd80e933666e07ed5b2f0d4062e28f5d0e4
7
- data.tar.gz: f14755645f55d6d954c3bd38668d961ce6121399d6b2f1dc5b13b25ed596f9c4f1527fd75ecf06391401f713653a621a6114f135b216ae77b5d6352046cd2693
6
+ metadata.gz: 9af8dd404a6cde1f6bba43b3de2df8ad9716c4b7fba0d06adbf020a89f032a624686b6aacaf899bfbf740ed163da8ff1fb17193167e834ea2643ee9377398c3a
7
+ data.tar.gz: 2cd5d57d28b64bd71bcfd8fc81e8201a5a749d2b8b50f2c1af45a99f62b2d52f0236a16fdf38ed7dde06443fa42501eee004e93fc921e1ba6bbad3c1ceef314d
@@ -65,6 +65,9 @@ Available options:"
65
65
  o.bool '--shallow',
66
66
  'Don\'t try to pull other wallets if their confirmations are required',
67
67
  default: false
68
+ o.bool '--deep',
69
+ 'Try to pull other wallets if their confirmations are required, as deep as possible',
70
+ default: false
68
71
  o.bool '--allow-negative-balance',
69
72
  'Don\'t check for the negative balance of the wallet after the merge',
70
73
  default: false
@@ -143,13 +146,14 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
143
146
  @log.debug("Building a patch for #{wallet.id} from remote copy ##{name} with #{wallet.mnemo}...")
144
147
  if opts['shallow']
145
148
  patch.join(wallet, ledger: opts['ledger']) do |txn|
146
- @log.debug("Paying wallet #{txn.bnf} file is absent but it's a \"shallow\" MERGE: #{txn.to_text}")
149
+ @log.debug("Paying wallet #{txn.bnf} file is in question but it's a \"shallow\" MERGE: #{txn.to_text}")
147
150
  false
148
151
  end
149
152
  else
150
153
  patch.join(wallet, ledger: opts['ledger']) do |txn|
151
154
  Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
152
- ['pull', txn.bnf.to_s, "--network=#{opts['network']}", '--shallow', '--quiet-if-absent']
155
+ ['pull', txn.bnf.to_s, "--network=#{opts['network']}", '--quiet-if-absent'] +
156
+ (opts['deep'] ? ['--deep'] : ['--shallow'])
153
157
  )
154
158
  true
155
159
  end
@@ -82,6 +82,10 @@ module Zold
82
82
  sleep 0.2
83
83
  return
84
84
  end
85
+ if @remotes.all.empty?
86
+ @log.debug("Can't hungry-pull #{id}, the list of remotes is empty")
87
+ return
88
+ end
85
89
  begin
86
90
  Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
87
91
  ['pull', id.to_s, "--network=#{@network}", '--tolerate-edges', '--tolerate-quorum=1']
@@ -24,6 +24,7 @@ STDOUT.sync = true
24
24
 
25
25
  require 'get_process_mem'
26
26
  require 'thin'
27
+ require 'haml'
27
28
  require 'json'
28
29
  require 'sinatra/base'
29
30
  require 'concurrent'
@@ -54,6 +55,8 @@ module Zold
54
55
  MIN_SCORE = 4
55
56
 
56
57
  configure do
58
+ Haml::Options.defaults[:format] = :xhtml
59
+ set :views, (proc { File.expand_path(File.join(__dir__, '../../../views')) })
57
60
  Thread.current.name = 'sinatra'
58
61
  set :bind, '0.0.0.0'
59
62
  set :suppress_messages, true
@@ -93,7 +96,7 @@ module Zold
93
96
  Thread.current.thread_variable_set(:ip, request.ip)
94
97
  @start = Time.now
95
98
  if !settings.opts['halt-code'].empty? && params[:halt] && params[:halt] == settings.opts['halt-code']
96
- settings.log.error('Halt signal received, shutting the front end down...')
99
+ settings.log.info('Halt signal received, shutting the front end down...')
97
100
  Front.stop!
98
101
  end
99
102
  check_header(Http::NETWORK_HEADER) do |header|
@@ -320,38 +323,15 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
320
323
 
321
324
  get %r{/wallet/(?<id>[A-Fa-f0-9]{16})\.html} do
322
325
  fetch('text/html') do |wallet|
323
- [
324
- '<!DOCTYPE html><html><head>',
325
- '<title>' + wallet.id.to_s + '</title>',
326
- '<link href="https://cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css-1.4.2.min.css" rel="stylesheet"/>',
327
- '<style>table { width: 100%; } td, th { padding: 0.2em .4em }</style>',
328
- '</head><body><section>',
329
- "<p>#{wallet.network}<br/>",
330
- "#{wallet.protocol}<br/>",
331
- "#{wallet.id}<br/>",
332
- "#{wallet.key.to_pub}</p>",
333
- '<table><thead><tr><th>Id</th><th>Date</th><th>Amount</th><th>Wallet</th><th>Details</th></thead>',
334
- '<tbody>',
335
- wallet.txns.map do |t|
336
- [
337
- '<tr>',
338
- '<td style="color:' + (t.amount.negative? ? 'red' : 'green') + "\">#{t.id}</td>",
339
- "<td>#{t.date.utc.iso8601}</td>",
340
- '<td style="text-align:right">' + t.amount.to_zld(4) + '</td>',
341
- "<td><a href='/wallet/#{t.bnf}.html'><code>#{t.bnf}</code></a></td>",
342
- "<td>#{CGI.escapeHTML(t.details)}</td>",
343
- '</tr>'
344
- ].join
345
- end.join,
346
- '<p>&mdash;<br/>',
347
- "Balance: #{wallet.balance.to_zld(8)} ZLD (#{wallet.balance.to_i} zents)<br/>",
348
- "Transactions: #{wallet.txns.count}<br/>",
349
- "Taxes: #{Tax.new(wallet).paid} paid, the debt is #{Tax.new(wallet).debt}<br/>",
350
- "File size: #{Size.new(wallet.size)}/#{wallet.size}, \
351
- #{Copies.new(File.join(settings.copies, wallet.id)).all.count} copies<br/>",
352
- "Modified: #{wallet.mtime.utc.iso8601} (#{Age.new(wallet.mtime.utc.iso8601)} ago)<br/>",
353
- "Digest: <code>#{wallet.digest}</code></p></section></body></html>"
354
- ].join
326
+ haml(
327
+ :wallet,
328
+ layout: :layout,
329
+ locals: {
330
+ title: wallet.id.to_s,
331
+ description: "Zold wallet #{wallet.id} at #{settings.address}",
332
+ wallet: wallet
333
+ }
334
+ )
355
335
  end
356
336
  end
357
337
 
@@ -482,17 +462,19 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
482
462
 
483
463
  get '/journal' do
484
464
  content_type('text/html')
485
- [
486
- '<!DOCTYPE html><html><head>',
487
- '<title>/journal</title>',
488
- '<link href="https://cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css-1.4.2.min.css" rel="stylesheet"/>',
489
- '</head><body><section>',
490
- DirItems.new(settings.journal_dir).fetch.sort.map do |f|
491
- file = File.join(settings.journal_dir, f)
492
- "<p><a href='/journal/item?id=#{f}'>#{f}</a>: #{File.size(file)} #{Age.new(File.mtime(file))} ago</p>"
493
- end.join,
494
- '</section></body></html>'
495
- ].join
465
+ haml(
466
+ :journal,
467
+ layout: :layout,
468
+ locals: {
469
+ title: '/journal',
470
+ description: 'The journal',
471
+ id: params[:id],
472
+ files: DirItems.new(settings.journal_dir).fetch.sort.reverse.select do |f|
473
+ !params[:id] || f.start_with?(params[:id])
474
+ end,
475
+ dir: settings.journal_dir
476
+ }
477
+ )
496
478
  end
497
479
 
498
480
  get '/journal/item' do
@@ -83,9 +83,10 @@ module Zold
83
83
  jlog = Logger.new(journal)
84
84
  jlog.level = Logger::DEBUG
85
85
  jlog.formatter = Log::COMPACT
86
- tlog = Log::Tee.new(log, jlog)
87
- tlog.info("push(#{id}, #{body.length} bytes)")
88
- @pipeline.push(id, body, JournaledPipeline::Wallets.new(wallets, jlog), tlog)
86
+ jlog.info("push(#{id}, #{body.length} bytes): starting...")
87
+ modified = @pipeline.push(id, body, JournaledPipeline::Wallets.new(wallets, jlog), Log::Tee.new(log, jlog))
88
+ jlog.info("push(#{id}): done")
89
+ modified
89
90
  end
90
91
  end
91
92
  end
@@ -87,7 +87,7 @@ module Zold
87
87
  Tempfile.open do |f|
88
88
  modified = Merge.new(
89
89
  wallets: wallets, remotes: @remotes, copies: copies.root, log: log
90
- ).run(['merge', id.to_s, "--ledger=#{f.path}", "--network=#{@network}"])
90
+ ).run(['merge', id.to_s, "--ledger=#{f.path}", "--network=#{@network}", '--deep'])
91
91
  @mutex.synchronize do
92
92
  txns = File.exist?(@ledger) ? IO.read(@ledger).strip.split("\n") : []
93
93
  txns += IO.read(f.path).strip.split("\n")
@@ -25,7 +25,7 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.26.17'
28
+ VERSION = '0.26.18'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
@@ -80,6 +80,7 @@ class FakeNode
80
80
  ensure
81
81
  Zold::Http.new(uri: uri + '?halt=test').get
82
82
  node.join
83
+ sleep 0.01 # stupid sleep to make sure all threads are terminated
83
84
  end
84
85
  end
85
86
  end
@@ -149,22 +149,23 @@ class FrontTest < Zold::Test
149
149
  end
150
150
  end
151
151
 
152
- def test_renders_wallet_pages
153
- FakeHome.new(log: test_log).run do |home|
154
- FakeNode.new(log: test_log).run(opts) do |port|
155
- wallet = home.create_wallet(txns: 2)
156
- base = "http://localhost:#{port}"
157
- response = Zold::Http.new(uri: "#{base}/wallet/#{wallet.id}").put(wallet.path)
158
- assert_equal(200, response.status, response.body)
159
- assert_equal_wait(200) { Zold::Http.new(uri: "#{base}/wallet/#{wallet.id}").get.status }
160
- [
161
- '.txt', '.html',
162
- '/balance', '/key', '/mtime',
163
- '/digest', '/size',
164
- '/age', '/mnemo', '/debt', '/txns',
165
- '/txns.json', '.bin', '/copies'
166
- ].each do |u|
167
- assert_equal_wait(200) { Zold::Http.new(uri: "#{base}/wallet/#{wallet.id}#{u}").get.status }
152
+ [
153
+ '.txt', '.html',
154
+ '/balance', '/key', '/mtime',
155
+ '/digest', '/size',
156
+ '/age', '/mnemo', '/debt', '/txns',
157
+ '/txns.json', '.bin', '/copies'
158
+ ].each do |p|
159
+ method = "test_wallet_page_#{p.gsub(/[^a-z]/, '_')}"
160
+ define_method(method) do
161
+ FakeHome.new(log: test_log).run do |home|
162
+ FakeNode.new(log: test_log).run(opts) do |port|
163
+ wallet = home.create_wallet(txns: 2)
164
+ base = "http://localhost:#{port}"
165
+ response = Zold::Http.new(uri: "#{base}/wallet/#{wallet.id}").put(wallet.path)
166
+ assert_equal(200, response.status, response.body)
167
+ assert_equal_wait(200) { Zold::Http.new(uri: "#{base}/wallet/#{wallet.id}").get.status }
168
+ assert_equal_wait(200) { Zold::Http.new(uri: "#{base}/wallet/#{wallet.id}#{p}").get.status }
168
169
  end
169
170
  end
170
171
  end
@@ -0,0 +1,19 @@
1
+ - if id
2
+ %p
3
+ Showing only wallet
4
+ %code= id
5
+
6
+ %table
7
+ %thead
8
+ %tr
9
+ %th File
10
+ %th Size
11
+ %th Modified
12
+ %tbody
13
+ - files.each do |f|
14
+ - file = File.join(dir, f)
15
+ %tr
16
+ %td
17
+ %a{href: '/journal/item?id=#{f}'}= f
18
+ %td.right= Zold::Size.new(File.size(file))
19
+ %td= "#{Zold::Age.new(File.mtime(file))} ago"
@@ -0,0 +1,32 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title= title
5
+ %meta{charset:'UTF-8'}
6
+ %meta{name: 'viewport', content: 'width=device-width, initial-scale=1.0'}
7
+ %meta{name: 'keywords', content: 'Zold, Cryptocurrency, Payments, Online Payments'}
8
+ %meta{name: 'description', content: description}
9
+ %link{rel: 'shortcut icon', href: '//www.zold.io/images/logo.png'}
10
+ %link{href: '//cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css-1.4.2.min.css', rel: 'stylesheet'}
11
+ %link{href: '//www.zold.io/0.13.3/css/main.min.css', rel: 'stylesheet'}
12
+ %meta{name: 'twitter:creator', content: '@0crat'}
13
+ %meta{name: 'twitter:site', content: '@0crat'}
14
+ %meta{name: 'twitter:title', property: 'og:title', content: 'Zold'}
15
+ %meta{name: 'twitter:description', property: 'og:description', content: 'Experimental Non-Blockchain Cryptocurrency for Fast Micropayments'}
16
+ %meta{name: 'twitter:url', property: 'og:url', content: request.url}
17
+ %meta{name: 'telegram:channel', content: 'zold_io'}
18
+ %meta{name: 'og:image', content: '//blog.zold.io/images/ledger.jpg'}
19
+ %meta{name: 'twitter:image', content: '//blog.zold.io/images/ledger.jpg'}
20
+ %meta{name: 'twitter:card', content: 'summary'}
21
+ %meta{name: 'twitter:image:alt', content: 'Zold'}
22
+ %body
23
+ %section
24
+ %p
25
+ %a{href: '/'}
26
+ %img.logo{src: '//www.zold.io/images/logo.svg', alt: 'Zold logo'}
27
+ = yield
28
+ %p.footnotes
29
+ = Zold::VERSION
30
+ %p
31
+ %a{href: 'https://github.com/zold-io/zold/stargazers'}
32
+ %img{src: '//img.shields.io/github/stars/zold-io/zold.svg?style=flat-square', alt: 'GitHub stars'}
@@ -0,0 +1,56 @@
1
+ %p
2
+ = wallet.network
3
+ %br
4
+ = wallet.protocol.to_s
5
+ %br
6
+ %code= wallet.id.to_s
7
+ %br
8
+ = wallet.key.to_pub.gsub(/([^ ]{16})/, '\1&shy;')
9
+
10
+ %table
11
+ %thead
12
+ %th
13
+ %th Id
14
+ %th Date
15
+ %th Amount
16
+ %th Wallet
17
+ %th Details
18
+ %tbody
19
+ - wallet.txns.each do |t|
20
+ %tr
21
+ - color = t.amount.negative? ? 'red' : 'green'
22
+ %td{style: "color:#{color};"}= t.id
23
+ %td= t.date.utc.iso8601
24
+ %td{style:"text-align:right;color:#{color};"}= t.amount.to_zld(2)
25
+ %td
26
+ %a{href: "/wallet/#{t.bnf}.html"}
27
+ %code= t.bnf
28
+ %td= CGI.escapeHTML(t.details).gsub(/([^ ]{16})/, '\1&shy;')
29
+
30
+ %p
31
+ = '&mdash;'
32
+ %br
33
+ Balance:
34
+ = wallet.balance.to_zld(8)
35
+ ZLD
36
+ = "(#{wallet.balance.to_i} zents)"
37
+ %br
38
+ Transactions:
39
+ = wallet.txns.count
40
+ %br
41
+ Taxes:
42
+ = Zold::Tax.new(wallet).paid
43
+ paid, the debt is
44
+ = Zold::Tax.new(wallet).debt
45
+ %br
46
+ File size:
47
+ = "#{Zold::Size.new(wallet.size)}/#{wallet.size}"
48
+ = Zold::Copies.new(File.join(settings.copies, wallet.id)).all.count
49
+ copies
50
+ %br
51
+ Modified:
52
+ = wallet.mtime.utc.iso8601
53
+ = "(#{Zold::Age.new(wallet.mtime.utc.iso8601)} ago)"
54
+ %br
55
+ Digest:
56
+ %code= wallet.digest
@@ -66,6 +66,7 @@ and suggests a different architecture for digital wallet maintenance.'
66
66
  s.add_runtime_dependency 'diffy', '3.2.1'
67
67
  s.add_runtime_dependency 'futex', '>=0.8.5'
68
68
  s.add_runtime_dependency 'get_process_mem', '~>0.2'
69
+ s.add_runtime_dependency 'haml', '5.0.4'
69
70
  s.add_runtime_dependency 'json', '2.1.0'
70
71
  s.add_runtime_dependency 'memory_profiler', '0.9.12'
71
72
  s.add_runtime_dependency 'mimic', '0.4.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.17
4
+ version: 0.26.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-15 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: haml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 5.0.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 5.0.4
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: json
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -775,13 +789,16 @@ files:
775
789
  - upgrades/move_wallets_into_tree.rb
776
790
  - upgrades/protocol_up.rb
777
791
  - upgrades/rename_foreign_wallets.rb
792
+ - views/journal.haml
793
+ - views/layout.haml
794
+ - views/wallet.haml
778
795
  - zold.gemspec
779
796
  homepage: http://github.com/zold-io/zold
780
797
  licenses:
781
798
  - MIT
782
799
  metadata: {}
783
800
  post_install_message: |-
784
- Thanks for installing Zold 0.26.17!
801
+ Thanks for installing Zold 0.26.18!
785
802
  Study our White Paper: https://papers.zold.io/wp.pdf
786
803
  Read our blog posts: https://blog.zold.io
787
804
  Try ZLD online wallet at: https://wts.zold.io