private final FreenetInterface freenetInterface;
private final SoneModificationDetector soneModificationDetector;
+ private final long delay;
/** The Sone to insert. */
private volatile Sone sone;
* The Sone to insert
*/
public SoneInserter(Core core, EventBus eventBus, FreenetInterface freenetInterface, Sone sone) {
+ this(core, eventBus, freenetInterface, sone, new SoneModificationDetector(core, sone, insertionDelay), 1000);
+ }
+
+ @VisibleForTesting
+ SoneInserter(Core core, EventBus eventBus, FreenetInterface freenetInterface, Sone sone, SoneModificationDetector soneModificationDetector, long delay) {
super("Sone Inserter for “" + sone.getName() + "”", false);
this.core = core;
this.eventBus = eventBus;
this.freenetInterface = freenetInterface;
this.sone = sone;
- this.soneModificationDetector = new SoneModificationDetector(core, sone, insertionDelay);
+ this.soneModificationDetector = soneModificationDetector;
+ this.delay = delay;
}
//
while (!shouldStop()) {
try {
/* check every second. */
- sleep(1000);
+ sleep(delay);
if (soneModificationDetector.isEligibleForInsert()) {
InsertInformation insertInformation = new InsertInformation(sone);