Advertisement
Guest User

Untitled

a guest
Apr 17th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/lib/blockchain/verified.js b/lib/blockchain/verified.js
  2. index e07613e..0ac0bfa 100644
  3. --- a/lib/blockchain/verified.js
  4. +++ b/lib/blockchain/verified.js
  5. @@ -230,11 +230,18 @@ function Verified (connector, opts) {
  6.    })
  7.    .then(function () {
  8.      function onConnect () {
  9. -      self.connector.getHeader('latest')
  10. -        .then(function (header) {
  11. -          return syncBlockchain(header.hash, header.height)
  12. -        })
  13. -        .catch(function (err) { self.emit('error', err) })
  14. +      Promise.try(function () {
  15. +        if (!self.isSyncing()) {
  16. +          self.emit('syncStart')
  17. +        }
  18. +      })
  19. +      .then(function () {
  20. +        return self.connector.getHeader('latest')
  21. +      })
  22. +      .then(function (header) {
  23. +        return syncBlockchain(header.hash, header.height)
  24. +      })
  25. +      .catch(function (err) { self.emit('error', err) })
  26.      }
  27.  
  28.      // run syncing using latest
  29. @@ -258,11 +265,6 @@ function Verified (connector, opts) {
  30.          .catch(function (err) { self.emit('error', err) })
  31.      })
  32.    })
  33. -  .finally(function () {
  34. -    if (self.isSyncing()) {
  35. -      self.emit('syncStop')
  36. -    }
  37. -  })
  38.  }
  39.  
  40.  inherits(Verified, Blockchain)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement