Move message_queue over to deduplication via intents

Due to each service having multiple distinct clocks, we can't expect a stable
ordering except the ordering an intact message-queue provides. The messages
emitted should be consistent however, solely with unknown order, which is why
we can craft intents based on their contents (already implemented by
processor-messages).
This commit is contained in:
Luke Parker
2023-07-16 20:32:04 -04:00
parent 23b9d57305
commit b0c28a1cf0
4 changed files with 12 additions and 5 deletions

View File

@@ -27,13 +27,13 @@ lazy_static::lazy_static! {
fn queue_message(meta: Metadata, msg: Vec<u8>, sig: SchnorrSignature<Ristretto>) {
{
let from = (*KEYS).read().unwrap()[&meta.from];
assert!(sig.verify(from, message_challenge(from, &msg, sig.R)));
assert!(sig.verify(from, message_challenge(from, meta.to, &meta.intent, &msg, sig.R)));
}
// Assert one, and only one of these, is the coordinator
assert!(matches!(meta.from, Service::Coordinator) ^ matches!(meta.to, Service::Coordinator));
// TODO: Verify the from_id hasn't been prior seen
// TODO: Verify the intent hasn't been prior seen
// Queue it
(*QUEUES).read().unwrap()[&meta.to].write().unwrap().queue_message(QueuedMessage {