From 410b5ffc9b14d60debc01b3cace3a1f3984ed7eb Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 19 Jul 2018 17:38:48 +0100 Subject: [PATCH] Events and skeleton of hashing service --- core/src/main/groovy/com/muwire/core/Event.groovy | 15 +++++++++++++++ .../com/muwire/core/files/FileHashedEvent.groovy | 8 ++++++++ .../com/muwire/core/files/FileSharedEvent.groovy | 8 ++++++++ .../com/muwire/core/files/HasherService.groovy | 5 +++++ 4 files changed, 36 insertions(+) create mode 100644 core/src/main/groovy/com/muwire/core/Event.groovy create mode 100644 core/src/main/groovy/com/muwire/core/files/FileHashedEvent.groovy create mode 100644 core/src/main/groovy/com/muwire/core/files/FileSharedEvent.groovy create mode 100644 core/src/main/groovy/com/muwire/core/files/HasherService.groovy diff --git a/core/src/main/groovy/com/muwire/core/Event.groovy b/core/src/main/groovy/com/muwire/core/Event.groovy new file mode 100644 index 00000000..4a9c0e94 --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/Event.groovy @@ -0,0 +1,15 @@ +package com.muwire.core + +import java.util.concurrent.atomic.AtomicLong + +class Event { + + private static final AtomicLong SEQ_NO = new AtomicLong(); + final long seqNo + final long timestamp + + Event() { + seqNo = SEQ_NO.getAndIncrement() + timestamp = System.currentTimeMillis() + } +} diff --git a/core/src/main/groovy/com/muwire/core/files/FileHashedEvent.groovy b/core/src/main/groovy/com/muwire/core/files/FileHashedEvent.groovy new file mode 100644 index 00000000..57d46237 --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/files/FileHashedEvent.groovy @@ -0,0 +1,8 @@ +package com.muwire.core.files + +import com.muwire.core.Event + +class FileHashedEvent extends Event { + + def sharedFile +} diff --git a/core/src/main/groovy/com/muwire/core/files/FileSharedEvent.groovy b/core/src/main/groovy/com/muwire/core/files/FileSharedEvent.groovy new file mode 100644 index 00000000..e26e81bc --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/files/FileSharedEvent.groovy @@ -0,0 +1,8 @@ +package com.muwire.core.files + +import com.muwire.core.Event + +class FileSharedEvent extends Event { + + File file +} diff --git a/core/src/main/groovy/com/muwire/core/files/HasherService.groovy b/core/src/main/groovy/com/muwire/core/files/HasherService.groovy new file mode 100644 index 00000000..04fc9910 --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/files/HasherService.groovy @@ -0,0 +1,5 @@ +package com.muwire.core.files + +class HasherService { + +}