// connectRPCClient attempts to establish an RPC connection to the created // dcrd process belonging to this Harness instance. If the initial connection // attempt fails, this function will retry h.maxConnRetries times, backing off // the time between subsequent attempts. If after h.maxConnRetries attempts, // we're not able to establish a connection, this function returns with an error. func (h *Harness) connectRPCClient() error { var client *rpc.Client var err error rpcConf := h.node.config.rpcConnConfig() for i := 0; i < h.maxConnRetries; i++ { if client, err = rpc.New(&rpcConf, h.handlers); err != nil { time.Sleep(time.Duration(math.Log(float64(i+3))) * 50 * time.Millisecond) continue } break } if client == nil { return fmt.Errorf("connection timed out: %v", err) } err = client.NotifyBlocks() if err != nil { return err } h.Node = client return nil }