aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2016-02-04 22:06:28 -0800
committerAdam Soltys <[email protected]>2016-02-04 22:06:28 -0800
commit083f14611eba89b47f681454509b0185e7deaa99 (patch)
tree4af93db7a4109fef33ac60023a12357513c8c73e
parentff5cbf6f07b664d681bbc97820e3e8c2cfede860 (diff)
downloadcoinos-server-083f14611eba89b47f681454509b0185e7deaa99.tar.gz
coinos-server-083f14611eba89b47f681454509b0185e7deaa99.zip
Prevent duplicate transaction logging
-rw-r--r--public/js/calculator.coffee17
-rw-r--r--public/js/calculator.js19
2 files changed, 22 insertions, 14 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee
index 9583a018..407a80f5 100644
--- a/public/js/calculator.coffee
+++ b/public/js/calculator.coffee
@@ -8,6 +8,7 @@ g = exports ? this
g.errors = []
g.amount_requested = 0
g.tip = 1
+g.transactions = []
$(->
$.ajax(
@@ -147,13 +148,15 @@ logTransaction = (txid, amount) ->
$('#success')[0].play()
g.user.index++
- $.post("/#{g.user.username}/transactions",
- txid: txid,
- address: g.user.address,
- date: moment().format("YYYY-MM-DD HH:mm:ss"),
- received: amount,
- exchange: g.exchange
- )
+ if g.transactions.indexOf(txid) is -1
+ g.transactions.push(txid)
+ $.post("/#{g.user.username}/transactions",
+ txid: txid,
+ address: g.user.address,
+ date: moment().format("YYYY-MM-DD HH:mm:ss"),
+ received: amount,
+ exchange: g.exchange
+ )
getAddress()
diff --git a/public/js/calculator.js b/public/js/calculator.js
index 4d0491cf..2808ad64 100644
--- a/public/js/calculator.js
+++ b/public/js/calculator.js
@@ -18,6 +18,8 @@
g.tip = 1;
+ g.transactions = [];
+
$(function() {
$.ajax({
url: $('#user').val() + '.json',
@@ -169,13 +171,16 @@
$('#received').fadeIn('slow');
$('#success')[0].play();
g.user.index++;
- $.post("/" + g.user.username + "/transactions", {
- txid: txid,
- address: g.user.address,
- date: moment().format("YYYY-MM-DD HH:mm:ss"),
- received: amount,
- exchange: g.exchange
- });
+ if (g.transactions.indexOf(txid) === -1) {
+ g.transactions.push(txid);
+ $.post("/" + g.user.username + "/transactions", {
+ txid: txid,
+ address: g.user.address,
+ date: moment().format("YYYY-MM-DD HH:mm:ss"),
+ received: amount,
+ exchange: g.exchange
+ });
+ }
return getAddress();
}
};