Created
July 15, 2020 15:23
-
-
Save daoka/096fa3f6484eefb22a3de6ffc024fed6 to your computer and use it in GitHub Desktop.
new block listener for 0.9.6
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
import { NetworkType, RepositoryFactoryHttp } from 'symbol-sdk'; | |
const apiEndpoint = 'https://sym-test963.opening-line.jp:3001'; | |
const wsEndpoint = `${apiEndpoint.replace('http', 'ws')}/ws` | |
const networkType = NetworkType.TEST_NET; | |
const generationHash = '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B'; | |
const repositoryFactory = new RepositoryFactoryHttp(apiEndpoint, { | |
networkType: networkType, | |
generationHash: generationHash, | |
websocketUrl: wsEndpoint, | |
}); | |
const listener = repositoryFactory.createListener(); | |
listener.open().then(() => { | |
listener.newBlock().subscribe( | |
(x) => { | |
console.log(`---- new block: ${x.height} ----`) | |
console.log(x); | |
}, (err) => { | |
console.error(err); | |
} | |
) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment