Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Commit

Permalink
Timeout Blockchain.info after 5 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
enriquez committed Apr 21, 2014
1 parent a3a5141 commit 5fcf5aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,14 @@ <h4 class="modal-title" id="myModalLabel">Welcome to Coin Pocket <small class="n
<script src="/js/views/connection_status_view.js"></script>
<script src="/js/controllers/welcome_modal_controller.js"></script>
<script src="/js/controllers/browser_controller.js"></script>
<script src="/js/controllers/balance_controller.js"></script>
<script src="/js/controllers/empty_state_controller.js"></script>
<script src="/js/controllers/confirmation_controller.js"></script>
<script src="/js/controllers/send_controller.js"></script>
<script src="/js/controllers/settings_controller.js"></script>
<script src="/js/controllers/receive_controller.js"></script>
<script src="/js/controllers/transaction_controller.js"></script>
<script src="/js/controllers/connection_status_controller.js"></script>
<script src="/js/controllers/balance_controller.js"></script>
<script src="/js/controllers/main_controller.js"></script>
<!-- /build -->

Expand Down
9 changes: 5 additions & 4 deletions app/js/models/block_height.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
BlockHeight.prototype.beginPolling = function() {
var self = this;

// try to get the block height ASAP
BitcoinNetwork.currentBlockHeight(function(height) {
self._triggerNewBlock(height);
});

// the socket doesn't always notify us, so we'll poll for it every 15 seconds :(
// it doesn't always give us the latest block height either :(
self.socket.onConnectSuccess(function() {
Expand All @@ -31,10 +36,6 @@
});

self.socket.onReconnectFailure(function() {
BitcoinNetwork.currentBlockHeight(function(height) {
self._triggerNewBlock(height);
});

setInterval(function() {
BitcoinNetwork.currentBlockHeight(function(height) {
self._triggerNewBlock(height);
Expand Down
3 changes: 3 additions & 0 deletions app/vendor/bitcoin_network/src/blockchaininfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var BlockChainInfo = (function(self, $) {
$.ajax({
type: 'GET',
url: url,
timeout: 5000,
data: { cors: 'true', format: 'json' },
success: function(data) {
hollaback(data, true);
Expand All @@ -24,6 +25,7 @@ var BlockChainInfo = (function(self, $) {
$.ajax({
type: 'GET',
url: url,
timeout: 5000,
data: { cors: 'true', format: 'json' },
success: function(data) {
hollaback(data, true);
Expand All @@ -45,6 +47,7 @@ var BlockChainInfo = (function(self, $) {
$.ajax({
type: 'POST',
url: url,
timeout: 5000,
data: postData,
success: function(res) {
hollaback(true, true);
Expand Down

0 comments on commit 5fcf5aa

Please sign in to comment.