koinos / koinos-p2p

The p2p microservice orchestrates the distribution of blocks and transactions between peers.
MIT License
6 stars 4 forks source link

Connect to seeds refactor #296

Closed mvandeberg closed 4 months ago

mvandeberg commented 5 months ago

Resolves #278

Brief description

Refactor the seed connection loop to prevent attempting to connect to an already connected seed.

Checklist

Demonstration

The only seeds the node is attempting to connect to are seeds that are down.

2024-06-14 12:38:52.350509 (p2p.YLJbz) [node/node.go:375] <info>: My address:
2024-06-14 12:38:52.350701 (p2p.YLJbz) [node/node.go:376] <info>:  - /ip4/127.0.0.1/tcp/8888/p2p/QmR6rdTe14uczcj8CRBk4jc7NHKHPXWxkDiPAompitGuzu
2024-06-14 12:38:52.350715 (p2p.YLJbz) [node/node.go:377] <info>: Connected peers:
2024-06-14 12:38:52.350746 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/95.216.68.185/tcp/8888/p2p/QmQzxW8XimrSyFDeNpd87WnwB54vVMR9tbiPqzykLT6K7F
2024-06-14 12:38:52.350762 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/95.216.2.248/tcp/8888/p2p/QmSt8SKKtsNWcBbx2WEZdiHKb4XGPZyVGK2bmgneFZyRcL
2024-06-14 12:38:52.350777 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/2.30.245.121/tcp/8888/p2p/QmeAHnanCapq1yY8cNkBA8gnv8k5YysaUCLGF7zeB59eTn
2024-06-14 12:38:52.350790 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/72.14.176.133/tcp/8888/p2p/Qmb25nNzd3rqJ2jgp7VXzvY6rgLft5fuuJNHSfeRBqqDJ7
2024-06-14 12:38:52.350804 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/192.241.151.61/tcp/8888/p2p/QmS2f5GrtaGRGonCHLTjVFzW5S3gEi1NhsbE1uLyxHzJYx
2024-06-14 12:38:52.350817 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/149.56.25.168/tcp/8888/p2p/QmTt887gBGH3U4ZfrdcFjkG6kMuqnbCcbaoG2FTDscS4bq
2024-06-14 12:38:52.350830 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/89.117.57.67/tcp/8888/p2p/Qme2HRSiGYfEA5fF7D5fjpAMsnd8dBs7rgFzN2CSHfhb9K
2024-06-14 12:38:52.350842 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/45.90.122.117/tcp/8888/p2p/QmXZ81KV2SxnBc1EiSGWvDT5VfaYCms1DE7sU2f11P625P
2024-06-14 12:38:52.350855 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/50.116.19.109/tcp/8888/p2p/Qmd2bkf65yCKVZb2PG3FiRQWzrYgKf47zGBFuoU5qdebEY
2024-06-14 12:38:52.350867 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/70.107.109.42/tcp/8888/p2p/QmYAC9nxqgVt2p8NvmxNFsoMpQS7c4zEBmsZndEBTRHNu4
2024-06-14 12:38:52.350879 (p2p.YLJbz) [node/node.go:379] <info>:  - /ip4/128.199.60.250/tcp/8888/p2p/QmNQf7mjYr5eFezUVpw6Vsa3Varu9YELB3Ysr3gK8QzGjf
2024-06-14 12:39:09.309748 (p2p.YLJbz) [p2p/connection_manager.go:257] <info>: Error connecting to seed QmcwsnczsFRxgkyYtTWK4dq6tbE5tpE48jtHp7nKAvy22V: failed to dial: failed to dial QmcwsnczsFRxgkyYtTWK4dq6tbE5tpE48jtHp7nKAvy22V:
  * [/ip4/172.26.0.6/tcp/8888] dial backoff
  * [/ip4/24.113.88.196/tcp/8888] dial backoff
  * [/ip4/24.113.70.146/tcp/8888] dial backoff
2024-06-14 12:39:09.309856 (p2p.YLJbz) [p2p/connection_manager.go:255] <info>: Attempting to connect to seed QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze
2024-06-14 12:39:28.430044 (p2p.YLJbz) [p2p/connection_manager.go:257] <info>: Error connecting to seed QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze: failed to dial: failed to dial QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze:
  * [/ip4/144.76.219.133/tcp/8888] dial backoff
  * [/ip4/172.18.0.36/tcp/8888] dial tcp4 172.18.0.36:8888: i/o timeout
2024-06-14 12:39:38.430735 (p2p.YLJbz) [p2p/connection_manager.go:255] <info>: Attempting to connect to seed QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze
2024-06-14 12:39:43.898625 (p2p.YLJbz) [p2p/connection_manager.go:257] <info>: Error connecting to seed QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze: failed to dial: failed to dial QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze:
  * [/ip4/172.18.0.36/tcp/8888] dial backoff
  * [/ip4/144.76.219.133/tcp/8888] dial backoff