classifyPrefix
Classify which "sub-branch" of a bucket nid falls into, using the few bits after the bucket's shared prefix. Port of std::uint8_t classify_prefix(int bucket_idx, bool last_bucket, int bucket_size, node_id nid).
The return value is in 0 until bucketSize. replaceNodeImpl uses it to keep a good spread of ids in each bucket so that lookups branch out evenly.
Parameters
lastBucket
whether this is the routing table's last (not-yet-split) bucket; the last bucket still holds entries from "both sides" so its top defining bit is included (one fewer left-shift).
bucketSizeLimit
the bucket's size limit; must be a power of two ≤ 256.