lib/zold/commands/propagate.rb in zold-0.14.50 vs lib/zold/commands/propagate.rb in zold-0.14.51
- old
+ new
@@ -61,23 +61,28 @@
# Returns list of Wallet IDs which were affected
def propagate(id, _)
start = Time.now
modified = []
+ total = 0
@wallets.find(id) do |wallet|
wallet.txns.select { |t| t.amount.negative? }.each do |t|
- next if t.bnf == id
+ total += 1
+ if t.bnf == id
+ @log.error("Paying itself in #{id}? #{t}")
+ next
+ end
@wallets.find(t.bnf) do |target|
unless target.exists?
@log.debug("#{t.amount * -1} to #{t.bnf}: wallet is absent")
next
end
unless target.network == wallet.network
@log.error("#{t.amount * -1} to #{t.bnf}: network mismatch, '#{target.network}'!='#{wallet.network}'")
next
end
- next if target.has?(t.id, id)
+ next if target.includes_positive?(t.id, id)
unless target.prefix?(t.prefix)
@log.error("#{t.amount * -1} to #{t.bnf}: wrong prefix")
next
end
target.add(t.inverse(id))
@@ -85,10 +90,11 @@
modified << t.bnf
end
end
end
modified.uniq!
- @log.debug("Wallet #{id} propagated successfully in #{Age.new(start)}, #{modified.count} wallets affected")
+ @log.debug("Wallet #{id} propagated successfully, #{total} txns in #{Age.new(start)}, \
+#{modified.count} wallets affected")
modified
end
end
end