feat: use canonical peer priority to decide which peers to keep (#6981)

* feat: CRC32-C

* feat: canonical peer priority calculation bep-40

* test: add test cases for IPv4 canonical peer priority

* refactor: compare by canonical priority

* fix: use network byte order for peer ports

* test: more cases

* build: xcode

Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* ci: test system crc32c library

---------

Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>
This commit is contained in:
Yat Ho
2025-10-26 01:05:20 +08:00
committed by GitHub
parent e7d4a69107
commit 0715897fc8
14 changed files with 560 additions and 15 deletions

30
cmake/FindCRC32C.cmake Normal file
View File

@@ -0,0 +1,30 @@
if(CRC32C_PREFER_STATIC_LIB)
set(CRC32C_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
endif()
find_path(CRC32C_INCLUDE_DIR
NAMES crc32c/crc32c.h)
find_library(CRC32C_LIBRARY
NAMES crc32c)
set(CRC32C_INCLUDE_DIRS ${CRC32C_INCLUDE_DIR})
set(CRC32C_LIBRARIES ${CRC32C_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CRC32C
REQUIRED_VARS
CRC32C_INCLUDE_DIR
CRC32C_LIBRARY)
mark_as_advanced(CRC32C_INCLUDE_DIR CRC32C_LIBRARY)
if(CRC32C_PREFER_STATIC_LIB)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CRC32C_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(CRC32C_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()