Guest User

Untitled

a guest
Oct 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. fileprivate func startNode() throws {
  2. var error: NSError?
  3. let bootNodes = GethNewEnodesEmpty()
  4. bootNodes?.append(GethNewEnode(Constants.Ethereum.enodeRawUrl, &error))
  5.  
  6. let genesisPath = Bundle.main.path(forResource: "rinkeby", ofType: "json")
  7. let genesis = try! String(contentsOfFile: genesisPath!, encoding: String.Encoding.utf8)
  8.  
  9. let config = GethNewNodeConfig()
  10. config?.setBootstrapNodes(bootNodes)
  11. config?.setEthereumGenesis(genesis)
  12. config?.setEthereumNetworkID(4)
  13.  
  14. let datadir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
  15. ethereumNode = GethNewNode(datadir, config, &error)
  16.  
  17. try ethereumNode.start()
  18.  
  19. if let error = error {
  20. throw EthereumError.nodeStartFailed(error: error)
  21. }
  22. }
  23.  
  24. fileprivate func startSync() throws {
  25. if let syncProgress = try? self.ethereumNode.getEthereumClient().syncProgress(self.ethereumContext) {
  26. self.isSyncMode = true
  27. } else if self.isSyncMode {
  28. self.isSyncMode = false
  29. }
  30. }
Add Comment
Please, Sign In to add comment