Bitcoin Forum
May 10, 2024, 09:34:47 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Salient block countdown timer  (Read 3656 times)
Meni Rosenfeld (OP)
Donator
Legendary
*
Offline Offline

Activity: 2058
Merit: 1054



View Profile WWW
November 26, 2012, 09:04:07 AM
 #1

The block reward halving is upon us, and people celebrating need a way to be informed at the moment of the event. The go-to link right now is bitcoinclock.com, but AFAIK it doesn't actually do anything when the event happens.

With the help of gweedo, I bring you the Block halving party countdown, as a service to those who wish a salient way to pinpoint the exact time to begin the festivities.

You can set as a parameter the block you wish to celebrate (default is 209999, the last block with 50 BTC reward, after which the network starts working on a 25 BTC block).

When the target block is found, the background becomes green and 3 beeps are sounded. A block before that the background is orange and 1 beep is sounded, and two blocks before the target the background is red.

It uses blockexplorer.com data, so should be about as accurate as it.

You can try it out with a nearby target to test it and become familiar with the functionality.

The code consists of 2 files:

getBlockHeight.php:
Code:
<?php
$ch 
curl_init("https://blockexplorer.com/q/getblockcount");
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
echo 
curl_exec($ch);
curl_close($ch);
?>


index.php:
Code:
<?php
$height
=209999;
if(isset(
$_GET['i'])){
    
$height=$_GET['i'];
}
?>

<html>
<head>
<title>Block halving party countdown</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://raw.github.com/egonelbre/jsfx/master/lib/audio.js" type="text/javascript"></script>
<script src="https://raw.github.com/egonelbre/jsfx/master/lib/jsfx.js" type="text/javascript"></script>
<script src="https://raw.github.com/egonelbre/jsfx/master/lib/jsfxlib.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var height=parseInt('<?php echo $height?>');
var sound = jsfxlib.createWave(["saw",0.0000,0.4000,0.0000,0.1320,0.0000,0.1020,20.0000,638.0000,2400.0000,0.0000,0.0000,0.0000,0.0100,0.0003,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000,0.0000,0.0000,0.1000,0.0000]);
var lastheight=0;
var extrabeeps=0;
check();
self.setInterval(function(){check()},1000);
function check(){
        var currentheight;
        $.get('getBlockHeight.php', function(res) {
        currentheight=parseInt(res);
        if (extrabeeps>0)
        {
        sound.play();
        extrabeeps--;
        }
        if(currentheight>lastheight&&lastheight<height)
        {
        if((height-2)>currentheight){
              $('body').css("background-color","white");
        }else if((height-2)==currentheight){
                            $('body').css("background-color","red");
        }else if((height-1)==currentheight){
                            $('body').css("background-color","orange");
                            sound.play();
        }else if(height<=currentheight){
                            $('body').css("background-color","green");
                             sound.play();
                             extrabeeps=2;
        }
        }
        lastheight=currentheight;
        if(height>currentheight){
          $('#amount').html(height-currentheight);
         }else if(height<=currentheight){
           $('h1').html("HAPPY NEW REWARD!");
         }
        });
    }
});
</script>
</head>
<body>
<center>
<p>
<h1>Blocks remaining: <span id="amount"></span></h1>
<form method="get" action="index.php">
Enter your block height: <input type="text" name="i" /><br />
<input type="submit" value="Set" />
</form>
</p>
</center>
</body>
</html>

Enjoy!

1EofoZNBhWQ3kxfKnvWkhtMns4AivZArhr   |   Who am I?   |   bitcoin-otc WoT
Bitcoil - Exchange bitcoins for ILS (thread)   |   Israel Bitcoin community homepage (thread)
Analysis of Bitcoin Pooled Mining Reward Systems (thread, summary)  |   PureMining - Infinite-term, deterministic mining bond
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, but full nodes are more resource-heavy, and they must do a lengthy initial syncing process. As a result, lightweight clients with somewhat less security are commonly used.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715376887
Hero Member
*
Offline Offline

Posts: 1715376887

View Profile Personal Message (Offline)

Ignore
1715376887
Reply with quote  #2

1715376887
Report to moderator
1715376887
Hero Member
*
Offline Offline

Posts: 1715376887

View Profile Personal Message (Offline)

Ignore
1715376887
Reply with quote  #2

1715376887
Report to moderator
J-Norm
Newbie
*
Offline Offline

Activity: 56
Merit: 0



View Profile
November 26, 2012, 04:08:28 PM
 #2

Funky tool. I love how high level languages and APIs make these sorts of tools very simple to construct.
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
November 26, 2012, 04:15:30 PM
 #3

I hope the miners have tested their block generation code. It would be a real anti-climax if the appointed block arrived and the generation failed to halve Smiley
Well, that would be an unhappy miner then because the block would be rejected as invalid and eventually someone will mine a 25 BTC block...

Miners get to choose which transactions get in their block - the "genesis" transactions out of thin air however are capped. Why else should they mine 50 BTC blocks if they could mine 1000 BTC blocks?

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
yogi
Legendary
*
Offline Offline

Activity: 947
Merit: 1042


Hamster ate my bitcoin


View Profile
November 26, 2012, 04:19:54 PM
 #4

Thanks!

Could you use the images in the 'Lets count to 21 million with images' thread as the count down?

Meni Rosenfeld (OP)
Donator
Legendary
*
Offline Offline

Activity: 2058
Merit: 1054



View Profile WWW
November 26, 2012, 06:15:56 PM
 #5

Could you use the images in the 'Lets count to 21 million with images' thread as the count down?
I don't consider this a desirable feature.

1EofoZNBhWQ3kxfKnvWkhtMns4AivZArhr   |   Who am I?   |   bitcoin-otc WoT
Bitcoil - Exchange bitcoins for ILS (thread)   |   Israel Bitcoin community homepage (thread)
Analysis of Bitcoin Pooled Mining Reward Systems (thread, summary)  |   PureMining - Infinite-term, deterministic mining bond
jgarzik
Legendary
*
Offline Offline

Activity: 1596
Merit: 1091


View Profile
November 26, 2012, 08:55:39 PM
 #6

Someone also put up http://bitcoinclock.com/

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Meni Rosenfeld (OP)
Donator
Legendary
*
Offline Offline

Activity: 2058
Merit: 1054



View Profile WWW
November 27, 2012, 08:03:22 AM
 #7

Someone also put up http://bitcoinclock.com/
I know and mentioned it in the OP. The problem is that as far as I know it doesn't do anything salient when the halving arrives.

1EofoZNBhWQ3kxfKnvWkhtMns4AivZArhr   |   Who am I?   |   bitcoin-otc WoT
Bitcoil - Exchange bitcoins for ILS (thread)   |   Israel Bitcoin community homepage (thread)
Analysis of Bitcoin Pooled Mining Reward Systems (thread, summary)  |   PureMining - Infinite-term, deterministic mining bond
phelix
Legendary
*
Offline Offline

Activity: 1708
Merit: 1020



View Profile
November 27, 2012, 10:25:17 PM
 #8

 Smiley

does not work for me with fox. chrome is ok.
Meni Rosenfeld (OP)
Donator
Legendary
*
Offline Offline

Activity: 2058
Merit: 1054



View Profile WWW
November 28, 2012, 06:21:25 AM
 #9

Smiley

does not work for me with fox. chrome is ok.
I can't reproduce, for me it works on both. Though strangely, it now takes 10-20 seconds to load, earlier it was faster.

1EofoZNBhWQ3kxfKnvWkhtMns4AivZArhr   |   Who am I?   |   bitcoin-otc WoT
Bitcoil - Exchange bitcoins for ILS (thread)   |   Israel Bitcoin community homepage (thread)
Analysis of Bitcoin Pooled Mining Reward Systems (thread, summary)  |   PureMining - Infinite-term, deterministic mining bond
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!