github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/cmd/puppeth/wizard_explorer.go (about) 1 2 //此源码被清华学神尹成大魔王专业翻译分析并修改 3 //尹成QQ77025077 4 //尹成微信18510341407 5 //尹成所在QQ群721929980 6 //尹成邮箱 yinc13@mails.tsinghua.edu.cn 7 //尹成毕业于清华大学,微软区块链领域全球最有价值专家 8 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 9 //版权所有2017 Go Ethereum作者 10 //此文件是Go以太坊的一部分。 11 // 12 //Go以太坊是免费软件:您可以重新发布和/或修改它 13 //根据GNU通用公共许可证的条款 14 //自由软件基金会,或者许可证的第3版,或者 15 //(由您选择)任何更高版本。 16 // 17 //Go以太坊的分布希望它会有用, 18 //但没有任何保证;甚至没有 19 //适销性或特定用途的适用性。见 20 //GNU通用公共许可证了解更多详细信息。 21 // 22 //你应该已经收到一份GNU通用公共许可证的副本 23 //一起去以太坊吧。如果没有,请参见<http://www.gnu.org/licenses/>。 24 25 package main 26 27 import ( 28 "encoding/json" 29 "fmt" 30 "time" 31 32 "github.com/ethereum/go-ethereum/log" 33 ) 34 35 // 36 func (w *wizard) deployExplorer() { 37 // 38 if w.conf.Genesis == nil { 39 log.Error("No genesis block configured") 40 return 41 } 42 if w.conf.ethstats == "" { 43 log.Error("No ethstats server configured") 44 return 45 } 46 if w.conf.Genesis.Config.Ethash == nil { 47 log.Error("Only ethash network supported") 48 return 49 } 50 // 51 server := w.selectServer() 52 if server == "" { 53 return 54 } 55 client := w.servers[server] 56 57 // 58 infos, err := checkExplorer(client, w.network) 59 if err != nil { 60 infos = &explorerInfos{ 61 nodePort: 30303, webPort: 80, webHost: client.server, 62 } 63 } 64 existed := err == nil 65 66 chainspec, err := newParityChainSpec(w.network, w.conf.Genesis, w.conf.bootnodes) 67 if err != nil { 68 log.Error("Failed to create chain spec for explorer", "err", err) 69 return 70 } 71 chain, _ := json.MarshalIndent(chainspec, "", " ") 72 73 // 74 fmt.Println() 75 fmt.Printf("Which port should the explorer listen on? (default = %d)\n", infos.webPort) 76 infos.webPort = w.readDefaultInt(infos.webPort) 77 78 // 79 if infos.webHost, err = w.ensureVirtualHost(client, infos.webPort, infos.webHost); err != nil { 80 log.Error("Failed to decide on explorer host", "err", err) 81 return 82 } 83 //找出用户希望存储持久数据的位置 84 fmt.Println() 85 if infos.datadir == "" { 86 fmt.Printf("Where should data be stored on the remote machine?\n") 87 infos.datadir = w.readString() 88 } else { 89 fmt.Printf("Where should data be stored on the remote machine? (default = %s)\n", infos.datadir) 90 infos.datadir = w.readDefaultString(infos.datadir) 91 } 92 // 93 fmt.Println() 94 fmt.Printf("Which TCP/UDP port should the archive node listen on? (default = %d)\n", infos.nodePort) 95 infos.nodePort = w.readDefaultInt(infos.nodePort) 96 97 // 98 fmt.Println() 99 if infos.ethstats == "" { 100 fmt.Printf("What should the explorer be called on the stats page?\n") 101 infos.ethstats = w.readString() + ":" + w.conf.ethstats 102 } else { 103 fmt.Printf("What should the explorer be called on the stats page? (default = %s)\n", infos.ethstats) 104 infos.ethstats = w.readDefaultString(infos.ethstats) + ":" + w.conf.ethstats 105 } 106 // 107 nocache := false 108 if existed { 109 fmt.Println() 110 fmt.Printf("Should the explorer be built from scratch (y/n)? (default = no)\n") 111 nocache = w.readDefaultString("n") != "n" 112 } 113 if out, err := deployExplorer(client, w.network, chain, infos, nocache); err != nil { 114 log.Error("Failed to deploy explorer container", "err", err) 115 if len(out) > 0 { 116 fmt.Printf("%s\n", out) 117 } 118 return 119 } 120 // 121 log.Info("Waiting for node to finish booting") 122 time.Sleep(3 * time.Second) 123 124 w.networkStats() 125 }