(config *cfg.Config, sw *p2p.Switch, p2pLogger log.Logger, nodeKey *p2p.NodeKey, )
| 612 | } |
| 613 | |
| 614 | func createAddrBookAndSetOnSwitch(config *cfg.Config, sw *p2p.Switch, |
| 615 | p2pLogger log.Logger, nodeKey *p2p.NodeKey, |
| 616 | ) (pex.AddrBook, error) { |
| 617 | addrBook := pex.NewAddrBook(config.P2P.AddrBookFile(), config.P2P.AddrBookStrict) |
| 618 | addrBook.SetLogger(p2pLogger.With("book", config.P2P.AddrBookFile())) |
| 619 | |
| 620 | // Add ourselves to addrbook to prevent dialing ourselves |
| 621 | if config.P2P.ExternalAddress != "" { |
| 622 | addr, err := p2p.NewNetAddressString(p2p.IDAddressString(nodeKey.ID(), config.P2P.ExternalAddress)) |
| 623 | if err != nil { |
| 624 | return nil, fmt.Errorf("p2p.external_address is incorrect: %w", err) |
| 625 | } |
| 626 | addrBook.AddOurAddress(addr) |
| 627 | } |
| 628 | if config.P2P.ListenAddress != "" { |
| 629 | addr, err := p2p.NewNetAddressString(p2p.IDAddressString(nodeKey.ID(), config.P2P.ListenAddress)) |
| 630 | if err != nil { |
| 631 | return nil, fmt.Errorf("p2p.laddr is incorrect: %w", err) |
| 632 | } |
| 633 | addrBook.AddOurAddress(addr) |
| 634 | } |
| 635 | |
| 636 | sw.SetAddrBook(addrBook) |
| 637 | |
| 638 | return addrBook, nil |
| 639 | } |
| 640 | |
| 641 | func createPEXReactorAndAddToSwitch(addrBook pex.AddrBook, config *cfg.Config, |
| 642 | sw *p2p.Switch, logger log.Logger, |
no test coverage detected