lib/zold/patch.rb in zold-0.26.7 vs lib/zold/patch.rb in zold-0.26.8
- old
+ new
@@ -81,12 +81,15 @@
end
unless wallet.id == @id
@log.error("Wallet ID mismatch, ours is #{@id}, theirs is #{wallet.id}")
return
end
+ seen = 0
+ added = 0
wallet.txns.each do |txn|
next if @txns.find { |t| t == txn }
+ seen += 1
if txn.amount.negative?
dup = @txns.find { |t| t.id == txn.id && t.amount.negative? }
if dup
@log.error("An attempt to overwrite existing transaction \"#{dup.to_text}\" \
with a new one \"#{txn.to_text}\" from #{wallet.mnemo}")
@@ -127,10 +130,11 @@
doesn't have this transaction: \"#{txn.to_text}\"")
next
end
end
@txns << txn
+ added += 1
if txn.amount.negative?
File.open(ledger, 'a') do |f|
f.puts(
[
Time.now.utc.iso8601,
@@ -145,9 +149,10 @@
)
end
end
@log.debug("Merged on top, balance is #{@txns.map(&:amount).inject(&:+)}: #{txn.to_text}")
end
+ @log.debug("#{seen} new txns arrived from #{wallet.mnemo}, #{added} of them added to the patch")
end
def empty?
@id.nil?
end