(config *cfg.Config, sw *p2p.Switch, p2pLogger log.Logger, nodeKey *p2p.NodeKey, )
| 598 | } |
| 599 | |
| 600 | func createAddrBookAndSetOnSwitch(config *cfg.Config, sw *p2p.Switch, |
| 601 | p2pLogger log.Logger, nodeKey *p2p.NodeKey, |
| 602 | ) (pex.AddrBook, error) { |
| 603 | addrBook := pex.NewAddrBook(config.P2P.AddrBookFile(), config.P2P.AddrBookStrict) |
| 604 | addrBook.SetLogger(p2pLogger.With("book", config.P2P.AddrBookFile())) |
| 605 | |
| 606 | // Add ourselves to addrbook to prevent dialing ourselves |
| 607 | if config.P2P.ExternalAddress != "" { |
| 608 | addr, err := p2p.NewNetAddressString(p2p.IDAddressString(nodeKey.ID(), config.P2P.ExternalAddress)) |
| 609 | if err != nil { |
| 610 | return nil, fmt.Errorf("p2p.external_address is incorrect: %w", err) |
| 611 | } |
| 612 | addrBook.AddOurAddress(addr) |
| 613 | } |
| 614 | if config.P2P.ListenAddress != "" { |
| 615 | addr, err := p2p.NewNetAddressString(p2p.IDAddressString(nodeKey.ID(), config.P2P.ListenAddress)) |
| 616 | if err != nil { |
| 617 | return nil, fmt.Errorf("p2p.laddr is incorrect: %w", err) |
| 618 | } |
| 619 | addrBook.AddOurAddress(addr) |
| 620 | } |
| 621 | |
| 622 | sw.SetAddrBook(addrBook) |
| 623 | |
| 624 | return addrBook, nil |
| 625 | } |
| 626 | |
| 627 | func createPEXReactorAndAddToSwitch(addrBook pex.AddrBook, config *cfg.Config, |
| 628 | sw *p2p.Switch, logger log.Logger, |
no test coverage detected