$ git grep "#include <event2"
// Just config
// configure.ac: #include <event2/http.h>
src/bitcoin-cli.cpp:#include <event2/buffer.h>
src/bitcoin-cli.cpp:#include <event2/keyvalq_struct.h>
// Done with https://github.com/bitcoin/bitcoin/pull/29904
src/common/url.cpp:#include <event2/http.h>
src/httpserver.cpp:#include <event2/buffer.h>
src/httpserver.cpp:#include <event2/bufferevent.h>
src/httpserver.cpp:#include <event2/http.h>
src/httpserver.cpp:#include <event2/http_struct.h>
src/httpserver.cpp:#include <event2/keyvalq_struct.h>
src/httpserver.cpp:#include <event2/thread.h>
src/httpserver.cpp:#include <event2/util.h>
// A hand full of raii inline wrappers
src/support/events.h:#include <event2/event.h>
src/support/events.h:#include <event2/http.h>
// Just tests
// src/test/fuzz/http_request.cpp:#include <event2/buffer.h>
// src/test/fuzz/http_request.cpp:#include <event2/event.h>
// src/test/fuzz/http_request.cpp:#include <event2/http.h>
// src/test/fuzz/http_request.cpp:#include <event2/http_struct.h>
// src/test/raii_event_tests.cpp:#include <event2/event.h>
src/torcontrol.cpp:#include <event2/buffer.h>
src/torcontrol.cpp:#include <event2/bufferevent.h>
src/torcontrol.cpp:#include <event2/event.h>
src/torcontrol.cpp:#include <event2/thread.h>
src/torcontrol.cpp:#include <event2/util.h>
// Done with XXX (pending some discussion on the TorControl callbacks)
src/torcontrol.h:#include <event2/util.h>
Basically, we have usage already nicely isolated in 4 files: bitcoin-cli.cpp
, httpserver.cpp
, support/events.h
, and torcontrol.cpp
where the support file can be almost ignored.
Getting libevent symbols
$ for file in /opt/homebrew/Cellar/libevent/2.1.12_1/lib/*.dylib; do
/usr/bin/nm -g "$file" | awk '{if (length($3) > 1 && substr($3, 1, 1) == "_") print substr($3, 2)}'
done | sort | uniq > libevent_symbols.txt
$ cat libevent_symbols.txt | wc -l
646
Getting the usage of symbols in each of our 4 files
$ grep -oFf libevent_symbols.txt ../bitcoin/src/httpserver.cpp | cut -c 2- | sort | uniq -c | wc -l
45
$ grep -oFf libevent_symbols.txt ../bitcoin/src/bitcoin-cli.cpp | cut -c 2- | sort | uniq -c | wc -l
15
$ grep -oFf libevent_symbols.txt ../bitcoin/src/support/events.h | cut -c 2- | sort | uniq -c | wc -l
6
$ grep -oFf libevent_symbols.txt ../bitcoin/src/torcontrol.cpp | cut -c 2- | sort | uniq -c | wc -l
20
How big is the overlap of all of the used symbols between these files?
$ grep -h -oFf libevent_symbols.txt ../bitcoin/src/httpserver.cpp ../bitcoin/src/bitcoin-cli.cpp ../bitcoin/src/support/events.h ../bitcoin/src/torcontrol.cpp | sort | uniq | wc -l
63
event2 in the current stable version includes 26 header files
$ find /opt/homebrew/Cellar/libevent/2.1.12_1/include/event2/ -type f -name "*.h" | wc -l
26
In the above grep you can see that we only use 8 of them:
event2/buffer.h
event2/bufferevent.h
event2/http.h
event2/http_struct.h
event2/keyvalq_struct.h
event2/thread.h
event2/util.h
event2/event.h