/// <summary> /// Determines whether a new anchor should be calculated and recorded, /// and does it if it is the case. /// </summary> /// <returns>The task object representing the asynchronous operation.</returns> public async Task <LedgerAnchor> RecordAnchor() { if (await anchorRecorder.CanRecordAnchor()) { LedgerAnchor anchor = await anchorState.GetLastAnchor(); LedgerAnchor latestAnchor = await ComputeNewAnchor(anchor); if (latestAnchor != null) { // Record the anchor await anchorRecorder.RecordAnchor(latestAnchor); // Commit the anchor if it has been recorded successfully await anchorState.CommitAnchor(latestAnchor); return(latestAnchor); } } return(null); }