Last active
          February 7, 2018 05:50 
        
      - 
      
- 
        Save subhodi/7f5c8b7f227fed60b1079e9a230ecd74 to your computer and use it in GitHub Desktop. 
    Useful scripts for Go-Ethereum command line
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Block with maximum transaction | |
| var max=0; | |
| for (var i = 0; i < eth.blockNumber; i++) { | |
| if (web3.eth.getBlock(max).transactions.length < web3.eth.getBlock(i).transactions.length) { | |
| console.log(i, web3.eth.getBlock(i).transactions.length); | |
| max = i; | |
| } | |
| } | |
| // auto-mining | |
| var mining_threads = 1 | |
| function checkWork() { | |
| if (eth.getBlock("pending").transactions.length > 0) { | |
| if (eth.mining) return; | |
| console.log("== Pending transactions! Mining..."); | |
| miner.start(mining_threads); | |
| } else { | |
| miner.stop(); | |
| console.log("== No transactions! Mining stopped."); | |
| } | |
| } | |
| eth.filter("latest", function(err, block) { checkWork(); }); | |
| eth.filter("pending", function(err, block) { checkWork(); }); | |
| checkWork(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment