Destroy peer in peer socket is closed or got an error.
Use TCP keepalive to detect dead peers.
Set feature macro with respect to detected C library.
Declare macros for TCP keepalive.
Move cmake toolchain files into a separate directory.
Correct clang toolchain file path.
Each exit path from a function should have appropriate return value.
Check type of method before calling handle_method.

This reduces the complexity a bit.
Make notify_fetching_peer externally visible.
Notify fetchers if a new state matches.
Merge if statement into the enclosing one.
Notify fetchers if a state changes.
Remove fetchers from states if a peer performing fetches dies.
Check return value of HASHTABLE_PUT against HASHTABLE_SUCCESS.
Check return value of HASHTABLE_PUT.
Implement unfetch operation.
Implement "fetch all".
Add some state traces for testing purposes.
Eliminate usage of cJSON_Add*ToObject.

These functions don't provide the necessary error handling capabilities.
Unify strings to save some memory.