以太坊出塊

以太坊計(jì)劃過度到pos共識(shí)機(jī)制,這使得挖礦變得過時(shí)。

  1. 開啟挖礦

    //--mine開啟挖礦,不帶這個(gè)參數(shù),啟動(dòng)的節(jié)點(diǎn)不會(huì)挖礦
    //--minnerthreads 挖礦的線程數(shù),默認(rèn)是CPU核心數(shù)
    geth --mine --minerthreads=1 
    
  2. 可以在console中開啟或者停止挖礦

    >miner.start(8) //開啟8個(gè)線程挖礦
    true
    >miner.stop() //停止挖礦
    true
    
  3. 設(shè)置挖礦收益賬號(hào)

    geth --etherbase 1 --mine //設(shè)置第二個(gè)賬號(hào)為挖礦收益賬號(hào)
    geth --etherbase '0x32a6d3706ac2f88c86058cf204f325fe0660038d' --mine //設(shè)置賬號(hào)地址為挖礦收益賬號(hào)
    
  4. 設(shè)置挖礦收益賬號(hào)(console)

    miner.setEtherbase(eth.accounts[2])
    
  5. 設(shè)置額外信息

    miner.setExtra("liangbin extra")
    
  6. 獲取計(jì)算hash速度 H/s(Hash operations per second)

    >miner.hashrate
    
  7. 獲取挖礦收益值

    > eth.getBalance(eth.coinbase).toNumber();
    70000000000000000000
    
  8. 解鎖賬號(hào),否則不能花費(fèi)以太

    > personal.unlockAccount(eth.coinbase)
    Unlock account 0x8cc4c2455b2d06b535606becc2f95e6a8b3ca258
    Passphrase: 
    true
    
  9. 查看哪些區(qū)塊是我挖出的

    1. 定義js方法并保存在/home/lb/go-ethereum1.8.4/jsdir/minedBlocks.js

      function minedBlocks(lastn, addr) {
        addrs = [];
        if (!addr) {
          addr = eth.coinbase
        }
        limit = eth.blockNumber - lastn
        for (i = eth.blockNumber; i >= limit; i--) {
          if (eth.getBlock(i).miner == addr) {
            addrs.push(i)
          }
        }
        return addrs
      }
      // scans the last 1000 blocks and returns the blocknumbers of blocks mined by your coinbase 
      // (more precisely blocks the mining reward for which is sent to your coinbase).   
      minedBlocks(1000, eth.coinbase);
      //[352708, 352655, 352559]
      
      1. 進(jìn)入console環(huán)境并加載js文件

        geth console
        > loadScript("/home/lb/go-ethereum1.8.4/jsdir/minedBlocks.js")
        true
        
      2. 調(diào)用方法

        > minedBlocks(20, eth.coinbase);
        [2318, 2317, 2316, 2315, 2314, 2313, 2312]
        

歡迎加入我的星球

我正在「哈斯卡和他的朋友們」和朋友們討論有趣的話題,你一起來吧


我的星球.jpg
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容