-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The socket initialization on line 10 can be used to check how the local implementation compares to the current decred insight server on mainnet.