概述
Windows通过geth同步以太坊区块数据
前言:为了便于测试,我决定在自己电脑同步eth区块数据,虽然中途遇到一些问题,但最终还是同步好了。记录一下,希望能帮到有需要的人~
一 下载geth客户端
既然是通过geth同步,那么肯定是需要下载geth客户端
的,同时,geth依赖于go语言环境,所以需要先安装go语言
。
安装go语言
,具体操作我就不说了,和安装jdk差不多,下载->安装->配置环境变量;下载geth
,点击这里下载geth,但是这个链接需要翻墙,不然好慢好慢,甚至打不开。怎么办?没事儿,我为大家准备好了,点我下载geth,提取码:qe2y
二 安装geth开始数据同步
第一步完成之后,安装到想要安装的目录,会生成一个geth.exe
程序。请不要直接执行该程序,因为这样的话,默认会把区块数据存放到C盘(系统盘),235G左右,显然不是我们希望看到的。
此外,就算你直接运行geth.exe程序,几乎不会同步数据,因为找不到节点进行数据同步,会一直Looking for peers
,但是这个问题在Linux服务器以及mac电脑不会发生,就windows系统会这样,本人亲测,也不知道为什么,这是歧视windos系统吗…
好了,废话不多说了,那么我们应该怎么做呢?
-
通过
cmd
进入到geth.exe程序所在目录,win10的快捷键是:按住shift
,然后单击鼠标右键
,然后点击在此处打开 Powershell窗口 (S)
。如下图所示:
关于启动命令,待会儿会做介绍。 -
通过以上命令启动的话,可以指定很多信息,但是还是没有解决我们的找不到节点进行数据同步问题。对于这个问题,我们需要
手动添加可用的以太坊节点
让我们的geth程序进行连接。
具体做法是新建一个static-nodes.json
文件,并设置为ANSI
格式,文件内容具就是可用的eth节点,这些节点从哪儿找呢?点我即可(我是官方节点),我已经帮大家找好了:
多说一句题外话,什么星火节点那些,都是不可用的,坑死人。我这个可用,我是从人家官网找来的。
["enode://424a7c4928abd10ebe806da151dd9ed4cdb0fb488e75897372a83c82cf93a94aa733cefbae81d3e983b2ca8479ae5385aa606098daf8cfbc97595888e5005761@68.185.171.253:30303",
"enode://2806db39202b7f345924d9a9f2e2d8561b8b8a6dec6ffadbfaf0a0a641051a9932fad4eb40628741c71ead5fa4969b154e496b9739702ddc3c534a691c32bfb0@52.220.200.137:30303",
"enode://494e031c90928d37b5949d6239d16a34a40af70e1bda3320f7c5fc21eb6b1532741fdd3eecf389cf738f8f3ea08b2be29e50777f4a57d4555a1546c5040ebc1a@51.107.0.221:30303",
"enode://440816b7671cae0eb83157d6c383f801f0810763562640a278df0fb0ae7382397883e452db23e7bd27b3a1e998faa6dcd4c0e5232b104ea77fac5722c9b3549d@40.67.144.128:30303",
"enode://c414216c4df5860800bafd83d003a9481a26244656b19f069b36d6a4f562e239c0f70c0094a81e122485f249f1f3b805af049fcf6b5c9f66af41b8d2b0206874@47.75.96.111:30303",
"enode://07fa090098a57a6a8ba03bb8ac6536cef105062eb1b53787089620cd605048e75abbb48e9332c398db4683bcf9a853fd17b9ddbeb4ec357d8e41b3a57110b08b@39.96.71.129:30303",
"enode://d7db90f17d9961b8d5e3be2d7df37e5b0d922e40e1672ca366cdaedd4c7d8d7951849435a52c7311732e865c817da6a4e441f3bace073ba054781628bd4b1965@47.75.212.121:30303",
"enode://ba7ac0d4b78a41f04c31971911cd85f2d99271353d44759105abaf584f8bc30ab5a080ec8506e03b76f3adf15c01a78cd78bc72e904e73d63265430523295bc8@47.90.22.194:30303",
"enode://17464b191b8b0d437acb51827af6392bb7836067d48259b546641bd2f74aa33cf7b2575fbef51ae6852137d6e90d243cf7c90b70b3d9887fd811d8623126ed41@148.66.48.50:30303",
"enode://886461da56051926fef25ec122095af1cfbc623e97f2f5531b5f3176f00ef4914a0e0dde69b5754b53859b796487a61b12543c52f983956d7b2aecd3918acc36@47.93.205.166:30303",
"enode://59ee2b7d04b8a481192c1109e6efd0facc26a0d8c1ee426b6ce09d6ff0edca9202e0096efc2d992d3f607b38307f32cfe20396970bbcc1384202694631da2970@52.91.9.107:30303",
"enode://4a8b75b3891f958f642003ed2dcc4ae4051417b7f7e753be91b6a9beecdddfa77683ba1740aa2c598c8eca06cfa8fe686dae1adf7903f83f779ddfe015a0f7af@87.150.161.246:30303",
"enode://a5fe788ee6edd27a117c68fa9883a886ae7d96f1f2a69b5af19178a091f19c32bddde01974c336f321a0eb9d0c60e53642dc7801f3faee1ac1b0ed982f0f2f65@47.52.247.211:30303",
"enode://18ae8f575a355833618b7b94a890647b3d35b029b6383c7c31c2f6f9dbefe6ff4b4a979df56a061f8f168a01f3d1c0ccea5085d7e587db35e02ad392f7b905e4@121.127.234.206:30303",
"enode://fe2075297f2a0118a1adfbb46ff0c775b25f51caa2901ca8ee8daed9d6745f8dd903557d8753762761832ec18435f0dcde6989e8a8a98ae5952b7242ebf92100@117.186.218.150:30303",
"enode://2629104604874f8ae34ed5614803658e3936495660c027e51edc04c34cc8360dc2f264281f43df11dabfcbd6867f6f89a2ab22fc94c22c0e3b962936f7a0b98e@120.27.69.141:30302",
"enode://147c1f8c11cc5b315fb884cae6339cff42fab0aacb124b7fd686071cda63b4f99466773187b97c9c268391f22fd1051b7040d8b22c210b536ff4031dfa2dd1ef@51.159.2.142:30303",
"enode://c7b87b01981fbfee67d0b0086dd079358f8a266635f5502f63286b592904d6cf83fe62b495e6f6127e6cc9134616b1b5a0c57244b807240a7ae28a10914330c0@3.227.211.201:30303",
"enode://f9a40ee5dd93b30357999f2ec965bfb1d57a7ff865088152c4c61dfb26e69d3aa755c74ca710cbf25bf9eb4ddb2f056a61adfb8ef371e61d362cfa6f58f940a9@211.63.212.24:30303",
"enode://82052dcf5729180fe5b44e78a1a65aa85459f56374c662967d7f9d5abaad929fdf5c00a92f1316dcc140ff31aaaa9c8a12bbd92288fc3be97ddfd37d0449417c@62.204.92.50:30303",
"enode://18e5f0351d3b3efc3b8201d29303beb9542503592c6800319fc58f7ac21f8b25015a3a59900cf78fd2b8f32eaced2c866212a02d65079dc9440e4effa373baa9@211.48.20.244:30303",
"enode://98dde5ca4c6d376798031a2c67b0da76460a1f8eccc93ee7b4c9b55c951ba5b22340b6eeab31ac95e9bedceb88e973042171d60b823ea711d2df03e440c64527@47.56.16.239:30303",
"enode://be32542e25b1a91c47652c381c98fcdadbfd6cb280c948c911ffa0f7a5951f464071d860685874e6e3b481adb306a2039fa6b3bfd774c4c57a9bceea2d6c73d2@139.9.32.85:30303",
"enode://fc73f1528df7b3d955e8e0b913d3481010d74c25242e4ced9eadbde5f57c2409827b0f516f26f66163f14d3c5bcc613c6252326015607ae388b361b640d31b87@34.207.226.9:30303",
"enode://8f39ce3401589cfec74f5a68b203306222c6ab5eebb66c47e62480b9a3263394328a7cd9b07821769187c7541806edde78fd6f954ba547e204581b36633fb989@95.217.114.28:30303",
"enode://0b22f86745c88d0e84f05ca554e1dd79dd2b0b188a9a7e69345bed6c4130a3d355e90932e6296db6bc1a59fd09b6de5750e27a3e133315d33f42985ed086b6fe@47.244.40.117:30303",
"enode://4724c0f517518628d6856dec4c975a406df3894c466cdb5687e70e5e32ea726907b730d15bfded95c93f87b1ef710d3d91349618fb12cdf6ddb717a6c864ea04@111.229.175.176:30303",
"enode://4bd96c8936641968980104cb7c27af8917993aef0150413e067b7c7ed88e66bd9b4b1f92a3d974e8cd6460721c3e7671bc830e1ef64e795d8ff417fc0b2d56f0@213.227.145.70:30303",
"enode://c3b998d0465761e89d8460aab45fd2627d103c3982eaefff1cd0b56fa0de0d08bfbda3b29370bf672adc7e30d601425f188ae3db66154e1a64f562afffd63999@47.102.103.87:30303",
"enode://50d966fbdd121104fd3634a059423df23edd5f1cc48a4d5e28a006af1259471cedf9da8cd08271ca1da0349ff53b00924354d4547067a2562aa0d8017ab44b77@34.90.106.130:30303",
"enode://2eb9336f7a17fd548adf90f2ea332c458aec8cc0926ea2d235d0e35d317847a91339bf5cc8b8c49a0a315cf36dda213518021477d6785ad5d630cdcec2f47c66@3.125.180.123:30303",
"enode://d143269d7c855375ed91698858e90cc44be63ee9118dd5eef0ac90717be8bb002d68cc6f055ac1de925cf4f34a60dd6e8930f3e307c31ca3ef66b8f60b582532@52.14.15.80:30303",
"enode://af89b6770f3d57a9df9c4460746a4beda13ef32ab132686769a207460e4cbd1d27edae3bc1621b53aea92f3ef574a8912ebeb06b65da519479f8630697b3bf5f@111.75.82.242:30303",
"enode://af7229c7415e05a5c2e83f08db6f08603ec3160996e91a68aaab7976a7b7edc60d08780dca3475b110718e982f7d1ad773fdd9632932de1525aaae38cff5f1bc@212.118.48.51:30303",
"enode://09c450259f66f69701d75ed158b7a165fa0020dc29a812b780bfd5e5891434a59255a22928350a5533f8db9ffd61807163f393aa813bd8d37b393af7d5d0cf45@199.231.166.242:30304",
"enode://80d47a0b1f9d5c5bdd5e84d46d866d55405a1b5cc2a7619381100e252f7910251546d95c1e4eafd9d2d4374310064dd77c7fb32166e0161fa13fb45807b7a7ab@34.73.250.160:30303",
"enode://004f9b9b2a99ae1a67287ba63ee8ab6a0462644000b1e7e2bb4c575b202a77525430e759912e3bd298645f081c2d787ceba24db129f54b7e559bface43d89196@18.215.193.84:30303",
"enode://2beff78adb78b13cbaf044bfac4ea783e38305915a9bcdc094999055e22ff392dc9584c59d254b93b276a052629ebccf35816db75ab260bc0c4f6eea9e2e254a@103.215.3.4:30303",
"enode://d4015b9d9d8e87cab29059f4b150cdd61978232d975610f7237897c399d4eba3a7e532b56b3c6c9621e955e55e3363e6fb39c236cfcedfc5f76f26f48c4c3488@125.212.226.194:30503",
"enode://f69001ddab2c55a68194f6429cc1ef8f511d20da6ab5ff1c3c5ebe6e3be220b67aa8a85b71a9cf7bc2e00ad72a8f3270523e82be4d2a3670b9c9b85205028738@54.234.72.148:30303",
"enode://6ddc13a247e21d5d751091f9ad3a152666f4872c4894a50718a2591208275bd25eb16cee50e2bdb5bae15a88794ffeac18e3d5904c6b69b907f9bb9f29794094@52.211.229.165:30500",
"enode://9f42cd377edc7f49c37c2582bbc46f1777d3ce4a52e3c21dfa5f05f4359bb29958c1b5bea69e8a3f484d721dcb8a6f6d3971b15f31a10ff2ca86d3fdc67fe56f@18.141.128.20:30303",
"enode://8e42a27c033a061023817cf135927043344d1daa606f4c263f81c16b733cbde5c301eebc2902e40611240a4f95015c9e7747b266206f1baf325db123b49a3932@47.108.199.215:30303",
"enode://784f2ee35f253013230f6e31caef30b15517ca1ab28cc6e308a79ec38e0323db14824c11635928ace66131640f07cb3070de1c3101abf610aeec1eb201cd8721@34.238.137.253:30303",
"enode://45f41356b06d2ef16dc3ecd52c569c436ad65516d55b8aee3a1750692e638e218b4f68d45c67d6540fdaa8a6970d9e2f8bcd6bbda8dd8d0285733b8aac727871@100.26.199.126:30303",
"enode://2ddb20350d305c6df0e6b157d501e2cb5d69c6eb90d53bbed00e34c9623eb4f6fffe0868dd24aadbf6e210229e222d91f39d6287aafe6cf812eeffd962bcdb2b@13.229.209.153:30303",
"enode://a80df7f333cc5e38f88a5a4a8febe71095054e8233c83f7182c51af252a7202a9c547cae0fa21b9ec4f12b09a45849042a04bb55c69347b155846da849584bb7@106.14.248.19:30303",
"enode://a879791b461fb7e01ce035682521b4f610a1b9ef86dae07a85d9e9ff21eb2dafc712bf99366589ca0971b4bf333d25d72a8df553222d5e87f25057ebf9a1604b@106.37.127.80:30303",
"enode://9de1cabecb6526cd3d86e51bf2353bdf43c5c5abbe92c9950d2589f8412f4db3ef2b57b95d830a41283d82484a4c35a264f71e1fa3f3262a089e5b95c40b1395@174.138.58.244:30303",
"enode://e3b37e66e092d6d463654735548846a6b1bb9a516e950966a7e8192cd6624f2c2990c4303d5bc9353a7d5ce94cc32c3c796431a424e53e73cd9f407966e3e0c3@47.98.236.104:30303"]
把以上内容复制到 static-nodes.json 文件
,
说了这么多,static-nodes.json
文件该放在哪里呢?—> 放在eth区块数据目录
下,就是上面的启动命令里面的--datadir
所设置的目录,我这里是 E:blockchainethethdata
目录。
该目录在geth程序启动之后,会生成geth
和keystore
目录。
三 geth程序启动命令详解
//windows下geth启动命令
./geth.exe --identity "ethnodebyczj" --datadir "E:/blockchain/eth/ethdata" --syncmode "fast" --rpc --rpcapi "admin,web3,eth,personal,miner,net" --rpcaddr 127.0.0.1 --rpcport 8545 --rpccorsdomain "*" --cache=3072 --maxpeers 1000 --maxpendpeers 900
//参数解析
--identity "ethnodebyczj" 给节点起名
--datadir "E:/blockchain/eth/ethdata" 将区块数据和keystore文件保存在 E:/blockchain/eth/ethdata 目录下
--syncmode "fast" 开启快速同步模式
--rpc 开启RPC服务
--rpcapi "admin,web3,eth,personal,miner,net" 注明要开启哪些RPC服务
--rpcaddr 0.0.0.0 指定RPC服务的IP
--rpcport 8545 指定RPC服务的端口
--rpccorsdomain "*" 允许跨域请求
--cache=3072 分配给Geth的内存,理论上越大同步速度越快
--maxpeers 1000 可连接的节点数量
--maxpendpeers 900 同上
再次强调:static-nodes.json
文件需要放在区块数据存储目录下,并且设置为ANSI格式
。
好了,以上就是windows下同步以太坊区块数据的过程,如果再有遇到什么问题,欢迎交流。
最后
以上就是高大超短裙为你收集整理的Windows通过geth同步以太坊区块数据的全部内容,希望文章能够帮你解决Windows通过geth同步以太坊区块数据所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复