lib/zold/node/front.rb in zold-0.16.26 vs lib/zold/node/front.rb in zold-0.16.27
- old
+ new
@@ -272,18 +272,30 @@
get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/age} do
fetch { |w| w.age.to_s }
end
- get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/mnemo} do
- fetch(&:mnemo)
+ get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/age} do
+ fetch { |w| w.age.to_s }
end
+ get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/txns} do
+ fetch { |w| w.txns.count.to_s }
+ end
+
+ get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/debt} do
+ fetch { |w| Tax.new(w).debt.to_i.to_s }
+ end
+
get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/digest} do
fetch(&:digest)
end
+ get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/mnemo} do
+ fetch(&:mnemo)
+ end
+
get %r{/wallet/(?<id>[A-Fa-f0-9]{16})\.txt} do
fetch do |wallet|
[
wallet.network,
wallet.protocol,
@@ -441,14 +453,11 @@
def processes
POSIX::Spawn::Child.new('ps', 'ax').out.split("\n").select { |t| t.include?('zold') }
end
def pretty(json)
- json.to_json
- # There seems to be some issue with memory leakage at this line, that's
- # why it's disabled for now:
- # JSON.pretty_generate(json)
+ JSON.pretty_generate(json)
end
def score
settings.zache.get(:score, lifetime: settings.opts['network'] == Wallet::MAIN_NETWORK ? 60 : 0) do
b = settings.farm.best
@@ -458,18 +467,12 @@
end
def fetch(type = 'text/plain')
error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
id = Id.new(params[:id])
- copy_of(id) do |wallet|
- content_type(type)
- yield wallet
- end
- end
-
- def copy_of(id)
settings.wallets.acq(id) do |wallet|
error(404, "Wallet ##{id} doesn't exist on the node") unless wallet.exists?
+ content_type(type)
yield wallet
end
end
def running_server?