`-b` means bootstrap mode. In this example, the go program is always the bootstrap node, so `-b` is always required.
Note that the node ID of `dht-interop` is always `Qm...6aJ9oRuEzWa` because it is being read in from `../util/private_key.bin` (a private key marshalled to X.509 generated by `util/private-key-gen`). This is to keep the peer id of the bootstrap server stable across invocations.
**Second terminal:** run the command printed out by dht-interop, replacing 127.0.0.1 with the IP of the server where dht-interop is listening. Example:
**Second terminal:** run the command printed out by dht-interop, replacing 127.0.0.1 with the IP of the server where dht-interop is listening. Example:
Note that the node ID of `dht-interop` is always `Qm...6aJ9oRuEzWa` because it is being read in from `util/private_key.bin` (a private key marshalled to X.509 generated by `util/private-key-gen`). This is to keep the peer id of the bootstrap server stable across invocations.
usage:=fmt.Sprintf("Usage: %s [-b] [PRIVATE_KEY]\n\n-b is bootstrap mode (creates DHT)\nPRIVATE_KEY is the path to a private key like '../util/private_key.bin'\n",os.Args[0])
varbBootstrapbool=false
varprivKeyFilePathstring
varargs[]string=os.Args[1:]
if(len(args)==0)||(len(args)>2){
fmt.Printf("Error: wrong number of arguments\n\n%s",usage)
os.Exit(1)
}
ifargs[0]=="-b"{
bBootstrap=true
args=args[1:]
}
privKeyFilePath=args[0]
returnbBootstrap,privKeyFilePath
}
funcmain(){
funcmain(){
ctx:=context.Background()
ctx:=context.Background()
bBootstrap,privKeyFilePath:=parseArgs()
if!bBootstrap{
fmt.Printf("Error: bootstrap mode required in this example")