In bplib_load the code retrieves the oldest active bundle from the storage service on every call to check if it has timed-out or expired. This retrieval from the storage service is unnecessary, and there are a few options to optimize it:
check the timeout using the active table retx time and only do a retrieval if it has timed out (this suffers from potentially leaving expired but not-timed-out bundles in the active table, since the expiration time is not stored in the active table)
move the expiration time into the active table and check both the timeout and the expiration time without doing a bundle retrieval.
In bplib_load the code retrieves the oldest active bundle from the storage service on every call to check if it has timed-out or expired. This retrieval from the storage service is unnecessary, and there are a few options to optimize it: