I'm not a massive fan of this opaque context parameter, it seems a bit fragile, with the encoding/decoding of context spread over multiple places in the function, i.e `x.received < int(context[1:])` is pretty cryptic. Couldn't you split it out into a message flag (either 's' or 'n') and the received time and pass these as two separate parameters into the function?