Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/services/anchor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ export class AnchorService {
}

try {
logger.imp(`Anchoring ${batchMessage.data.rids.length} requests from batch ${batchMessage.data.bid}`)
logger.imp(
`Anchoring ${batchMessage.data.rids.length} requests from batch ${batchMessage.data.bid}`
)
const requests = await this.requestRepository.findByIds(batchMessage.data.rids)

const requestsNotReplaced = requests.filter(
Expand Down Expand Up @@ -585,6 +587,7 @@ export class AnchorService {
anchors.length > 0
? await this.anchorRepository.withConnection(trx).createAnchors(anchors)
: 0
logger.imp(`Persisted ${persistedAnchorsCount} anchors to the database`)

await this.requestRepository.withConnection(trx).updateRequests(
{
Expand All @@ -594,12 +597,14 @@ export class AnchorService {
},
acceptedRequests
)
logger.imp(`Updated ${acceptedRequests.length} requests to COMPLETED status`)

// record some metrics about the timing and count of anchors
const completed = new TimeableMetric(SinceField.CREATED_AT)
completed.recordAll(acceptedRequests)
completed.publishStats(METRIC_NAMES.CREATED_SUCCESS_MS)
Metrics.count(METRIC_NAMES.ACCEPTED_REQUESTS, acceptedRequests.length)
logger.imp('Published metrics for completed requests')
return persistedAnchorsCount
},
{ isolationLevel: 'repeatable read' }
Expand Down