lib/blockchain_double.js
function(number, done) {
        try {
          number = to.number(number);
        } catch (e) {
          // Do nothing; must be a block hash.
        }

        self.getBlock(number, done);
      }
function(number, done) {
        try {
          number = to.number(number);
        } catch (e) {
          // Do nothing; must be a block hash.
        }

        self.getBlock(number, done);
      }
EthereumJS VM needs a blockchain object in order to get block information. When calling getBlock() it will pass a number that's of a Buffer type. Unfortunately, it uses a 64-character buffer (when converted to hex) to represent block numbers as well as block hashes. Since it's very unlikely any block number will get higher than the maximum safe Javascript integer, we can convert this buffer to a number ahead of time before calling our own getBlock(). If the conversion succeeds, we have a block number. If it doesn't, we have a block hash. (Note: Our implementation accepts both.)