Go-Ethereum

如何將本地 ganache 節點與 Epirus 連接

  • March 26, 2020

我嘗試將apirus連接到本地 ganache 節點。

Ganache 節點在 localhost:7545 上執行。

git clone https://github.com/blk-io/epirus-free.git
cd epirus-free
docker-compose pull
NODE_ENDPOINT=http://docker0:7545 docker-compose up

但無法連接。錯誤日誌顯示 docker0 是 unknowHost。

api_1      | 2020-03-26 07:05:52.323 ERROR 1 --- [   scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.
api_1      | 
api_1      | java.util.concurrent.CompletionException: java.net.UnknownHostException: docker0
api_1      |    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
api_1      |    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
api_1      |    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
api_1      |    at java.base/java.lang.Thread.run(Unknown Source)
api_1      | Caused by: java.net.UnknownHostException: docker0
api_1      |    at java.base/java.net.InetAddress$CachedAddresses.get(Unknown Source)
api_1      |    at java.base/java.net.InetAddress.getAllByName0(Unknown Source)
api_1      |    at java.base/java.net.InetAddress.getAllByName(Unknown Source)
api_1      |    at java.base/java.net.InetAddress.getAllByName(Unknown Source)
api_1      |    at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
api_1      |    at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:160)
api_1      |    at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:125)
api_1      |    at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:7

如何從 docker 容器連接到本地 ganache 節點?

按照blk-io/epirus/README中的步驟

請注意,如果將NODE_ENDPOINT設置為本地乙太坊實例,您可能需要使用與 Docker 橋接介面關聯的 IP 地址,通常用docker0表示。

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
       inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255

代替

NODE_ENDPOINT=http://docker0:7545 docker-compose up

它應該是

NODE_ENDPOINT=http://172.17.0.1:7545 docker-compose up

即,必須放置 docker0docker0的值。inet

引用自:https://ethereum.stackexchange.com/questions/80887