aboutsummaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-08-22 23:32:42 -0700
committerAdam Soltys <[email protected]>2014-08-22 23:32:42 -0700
commitdec12454289461e6851b3b7328b5a80f56ce4a98 (patch)
tree394b18ad2fe0d875a689e8acee4d918397845300 /public
parent11390ded587c17ca06535c0826f2d2da94417d93 (diff)
downloadcoinos-server-dec12454289461e6851b3b7328b5a80f56ce4a98.tar.gz
coinos-server-dec12454289461e6851b3b7328b5a80f56ce4a98.zip
Log txids and prevent duplicates
Diffstat (limited to 'public')
-rw-r--r--public/js/calculator.coffee19
1 files changed, 13 insertions, 6 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee
index c90954ab..e1e97cef 100644
--- a/public/js/calculator.coffee
+++ b/public/js/calculator.coffee
@@ -118,15 +118,18 @@ setupSocket = ->
g.blockchain.onmessage = (e) ->
results = eval('(' + e.data + ')')
- from_address = ''
- received = 0
+ amount_received = 0
+ txid = results.x.hash
+
+ return if txid == g.last
+ g.last = txid
$.each(results.x.out, (i, v) ->
if (v.addr == g.address)
- received += v.value / 100000000
+ amount_received += v.value / 100000000
)
- if $('#received').is(":hidden") and g.amount_requested <= received
+ if $('#received').is(":hidden") and g.amount_requested <= amount_received
$('#amount').blur()
$('#payment').hide()
$('#received').fadeIn('slow')
@@ -134,9 +137,9 @@ setupSocket = ->
if g.user
$.post("/#{g.user}/transactions",
- address: from_address,
+ txid: txid,
date: moment().format("YYYY-MM-DD HH:mm:ss"),
- received: received,
+ received: amount_received,
exchange: g.exchange
)
@@ -158,6 +161,10 @@ setupSocket = ->
g.btcd.onmessage = (e) ->
data = JSON.parse(e.data)
+ txid = data.result.txid
+ return if txid == g.last
+ g.last = txid
+
amount_received = 0
if data.result