Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const start = async () => {
- ...
- node.subscribe(channel.SYNC_BLOCK, async (buffer) => {
- const data = JSON.parse(buffer.data.toString())
- const currentNodeId = node.node.peerInfo.id.toB58String()
- if(data.nodeId == currentNodeId) {
- await bc.saveBlock(data.block)
- await bc.saveLatestHash(data.block.hash)
- await bc.clearSuccessTransactions(data.block.transactions)
- setTimeout(() => {
- node.publish(channel.SYNC_REQUEST, JSON.stringify({
- nodeId: currentNodeId,
- latestHash: data.block.hash,
- }))
- }, 2000)
- }
- })
- }
Add Comment
Please, Sign In to add comment