Skip to content

Commit

Permalink
fix(ref-imp): made Core event code consistent with bitcoin service
Browse files Browse the repository at this point in the history
  • Loading branch information
thehenrytsai committed Mar 16, 2021
1 parent 009202d commit 6abd2a1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions docs/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,12 @@ HTTP/1.1 200 OK

## Core Service Events

### `batch_writer_processing_loop_failed`
### `sidetree_batch_writer_loop_failure`
Occurs every time the batch writer fails a processing loop.

Event data: none

### `batch_writer_processing_loop_success`
### `sidetree_batch_writer_loop_success`
Occurs every time the batch writer completes a processing loop.

Event data:
Expand All @@ -709,7 +709,7 @@ Event data:
}
```

### `blockchain_time_changed`
### `sidetree_blockchain_time_changed`
Occurs every time the underlying blockchain time changes.

Event data:
Expand All @@ -719,7 +719,7 @@ Event data:
}
```

### `download_manager_download`
### `sidetree_download_manager_download`
Occurs every time an asynchronous content download has occurred regardless of success.

Event data:
Expand All @@ -729,12 +729,12 @@ Event data:
}
```

### `observer_processing_loop_failed`
### `sidetree_observer_loop_failure`
Occurs every time the observer fails a processing loop.

Event data: none

### `observer_processing_loop_success`
### `sidetree_observer_loop_success`
Occurs every time the observer completes a processing loop.

Event data: none
4 changes: 2 additions & 2 deletions lib/core/BatchScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export default class BatchScheduler {

const batchSize = await batchWriter.write();

EventEmitter.emit(EventCode.BatchWriterProcessingLoopSuccess, { batchSize });
EventEmitter.emit(EventCode.SidetreeBatchWriterLoopSuccess, { batchSize });
} catch (error) {
EventEmitter.emit(EventCode.BatchWriterProcessingLoopFailed);
EventEmitter.emit(EventCode.SidetreeBatchWriterLoopFailure);
Logger.error('Unexpected and unhandled error during batch writing, investigate and fix:');
Logger.error(error);
} finally {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/Blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default class Blockchain implements IBlockchain {

// Emit a time change event.
if (newBlockchainTimeModel.time !== this.cachedBlockchainTime.time) {
EventEmitter.emit(EventCode.BlockchainTimeChanged, { time: newBlockchainTimeModel.time });
EventEmitter.emit(EventCode.SidetreeBlockchainTimeChanged, { time: newBlockchainTimeModel.time });
}

// Update the cached blockchain time every time blockchain time is fetched over the network.
Expand Down
2 changes: 1 addition & 1 deletion lib/core/DownloadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class DownloadManager {
const fetchResult = this.completedDownloads.get(handle);
this.completedDownloads.delete(handle);

EventEmitter.emit(EventCode.DownloadManagerDownload, { code: fetchResult!.code });
EventEmitter.emit(EventCode.SidetreeDownloadManagerDownload, { code: fetchResult!.code });
return fetchResult!;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/core/EventCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* Event codes used by Sidetree core service.
*/
export default {
BatchWriterProcessingLoopFailed: 'batch_writer_processing_loop_failed',
BatchWriterProcessingLoopSuccess: 'batch_writer_processing_loop_success',
BlockchainTimeChanged: 'blockchain_time_changed',
DownloadManagerDownload: 'download_manager_download',
ObserverProcessingLoopFailed: 'observer_processing_loop_failed',
ObserverProcessingLoopSuccess: 'observer_processing_loop_success'
SidetreeBatchWriterLoopFailure: 'sidetree_batch_writer_loop_failure',
SidetreeBatchWriterLoopSuccess: 'sidetree_batch_writer_loop_success',
SidetreeBlockchainTimeChanged: 'sidetree_blockchain_time_changed',
SidetreeDownloadManagerDownload: 'sidetree_download_manager_download',
SidetreeObserverLoopFailure: 'sidetree_observer_loop_failure',
SidetreeObserverLoopSuccess: 'sidetree_observer_loop_success'
};
4 changes: 2 additions & 2 deletions lib/core/Observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ export default class Observer {
// Continue onto processing unresolvable transactions if any.
await this.processUnresolvableTransactions();

EventEmitter.emit(EventCode.ObserverProcessingLoopSuccess);
EventEmitter.emit(EventCode.SidetreeBatchWriterLoopSuccess);
} catch (error) {
EventEmitter.emit(EventCode.ObserverProcessingLoopFailed);
EventEmitter.emit(EventCode.SidetreeBatchWriterLoopFailure);
Logger.error(`Encountered unhandled and possibly fatal Observer error, must investigate and fix:`);
Logger.error(error);
} finally {
Expand Down

0 comments on commit 6abd2a1

Please sign in to comment.