forked from eoscanada/eos-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (32 loc) · 818 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"encoding/hex"
"flag"
"fmt"
"log"
"github.com/eoscanada/eos-go/p2p"
)
var peer = flag.String("peer", "localhost:9876", "peer to connect to")
var chainID = flag.String("chain-id", "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f", "net chainID to connect to")
var showLog = flag.Bool("v", false, "show detail log")
func main() {
flag.Parse()
if *showLog {
p2p.EnableP2PLogging()
}
defer p2p.SyncLogger()
cID, err := hex.DecodeString(*chainID)
if err != nil {
log.Fatal(err)
}
fmt.Println("P2P Client ", *peer, " With Chain ID :", *chainID)
client := p2p.NewClient(
p2p.NewOutgoingPeer(*peer, "eos-proxy", &p2p.HandshakeInfo{
ChainID: cID,
HeadBlockNum: 1,
}),
false,
)
client.RegisterHandler(p2p.StringLoggerHandler)
client.Start()
}