Skip to content

Instantly share code, notes, and snippets.

@oluwandabira
Last active May 18, 2018 22:58
Show Gist options
  • Save oluwandabira/9ac2fd59049dd19516616f96662f673f to your computer and use it in GitHub Desktop.
Save oluwandabira/9ac2fd59049dd19516616f96662f673f to your computer and use it in GitHub Desktop.
Test page that connects to the insight socket.io backend and logs new transactions and blocks.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<script src="http://localhost:7777/js/socket.io.slim.js"></script>
<script>
var socket = io('http://localhost:7777', {path: '/insight/socket.io', transports: ['websocket'], upgrade: false});
//var socket = io('https://mainnet.decred.org/')
socket.on('connect', function() {
socket.emit('subscribe', 'inv');
socket.emit('subscribe', 'sync');
})
socket.on('tx', function(data) {
console.log("New transaction received: " + JSON.stringify(data, null, 4))
})
socket.on('block', function(data) {
console.log("New block received: " + JSON.stringify(data, null, 4))
})
socket.on('status', function(data) {
console.log("Status: " + JSON.stringify(data, null, 4))
})
</script>
</body>
</html>
@oluwandabira
Copy link
Author

The socket initialization on line 10 can be used to check how the local implementation compares to the current decred insight server on mainnet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment