This PR cleans up code in the API that was duplicated in the various handle_* functions.
Creates a validate_request function to check for future timestamps, rate limiting, already inflight calls, and past timestamps not found in the rate cache.
Creates a charge_cycles function to handle the basic logic the occurs in the handle_* functions for charging cycles.
Adds a the following test: privileged callers cannot make requests containing timestamps in the future.
This PR cleans up code in the API that was duplicated in the various
handle_*
functions.validate_request
function to check for future timestamps, rate limiting, already inflight calls, and past timestamps not found in the rate cache.charge_cycles
function to handle the basic logic the occurs in thehandle_*
functions for charging cycles.