bcoin-org / bcoin

Javascript bitcoin library for node.js and browsers
https://bcoin.io
Other
3.02k stars 808 forks source link

TypeError: peer.blockMap.reset is not a function #274

Closed FallingSnow closed 7 years ago

FallingSnow commented 7 years ago

When I try node.stopSync() I get:

15:00:32.59 (process.<anonymous>) [index.js:4] <ERROR> Unhandled Rejection at: Promise Promise {
  <rejected> TypeError: peer.blockMap.reset is not a function
    at Pool.stopSync (/home/ayrton/Documents/universalis-socket/node_modules/bcoin/lib/net/pool.js:748:19)
    at FullNode.stopSync (/home/ayrton/Documents/universalis-socket/node_modules/bcoin/lib/node/fullnode.js:361:20)
    at process._callee2$ (/home/ayrton/Documents/universalis-socket/src/network/index.js:47:10)
    at tryCatch (/home/ayrton/Documents/universalis-socket/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/home/ayrton/Documents/universalis-socket/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (/home/ayrton/Documents/universalis-socket/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/home/ayrton/Documents/universalis-socket/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /home/ayrton/Documents/universalis-socket/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at Promise (<anonymous>)
    at F (/home/ayrton/Documents/universalis-socket/node_modules/core-js/library/modules/_export.js:35:28) } reason: TypeError: peer.blockMap.reset is not a function
    at Pool.stopSync (/home/ayrton/Documents/universalis-socket/node_modules/bcoin/lib/net/pool.js:748:19)
    at FullNode.stopSync (/home/ayrton/Documents/universalis-socket/node_modules/bcoin/lib/node/fullnode.js:361:20)
    at process._callee2$ (/home/ayrton/Documents/universalis-socket/src/network/index.js:47:10)
    at tryCatch (/home/ayrton/Documents/universalis-socket/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/home/ayrton/Documents/universalis-socket/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (/home/ayrton/Documents/universalis-socket/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/home/ayrton/Documents/universalis-socket/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /home/ayrton/Documents/universalis-socket/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at Promise (<anonymous>)
    at F (/home/ayrton/Documents/universalis-socket/node_modules/core-js/library/modules/_export.js:35:28)

Should peer.blockMap.reset(); be changed to peer.blockMap.clear(); since (if I'm not mistaken) peer.blockMap is a Map and has no documentation of a reset method.

When I make this change locally it seems to fix the issue.

chjj commented 7 years ago

Looks like the es6 map refactor caused this. Will fix.

FallingSnow commented 7 years ago

Thanks.