If I understand you correctly, you're looking for an efficient way to store an unordered list of six-byte tuples? I would have a monolithic backing store (two, if you need the bencoded and the bytes) with some clever optimizations for addition/removal.
1) A simple equation can be used to figure out where the Nth dataum is.
- For the IPs, it's 6*N for the IP, and 6*n+4 for the port, and you can pretty easily slice the right four bytes and cast it to a net.IP for your own use.
- For the bencoded values, a similar X+S*N equation should work, where X is the length of the bencoded header and S is the stride of the bencoded IP/port map.
2) When inserting a new value, append onto the backing store slice. This will probably require an rwmutex, tough you can write your own append to reduce the critical section and get a more scalable append.
3) When deleting a value, you can shorten the slice and copy the last value over the one you're deleting. This is less scalable (global rwmutex) but allows you to not have to iterate through a list on send, since it's already what you need.
4) If you can tolerate the two lists not being identical (you probably can), update them separately, with the more canonical source being updated first. This makes things more scalable because you're not locking down both lists for every delete/append.