Skip to content

Commit

Permalink
Added logging to transfer flow (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnickelsen authored Dec 19, 2024
1 parent 500dc08 commit 7b80361
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ public async Task<ExecutionResult> Execute(ExecuteContext<SendInformationToRecei
var externalEndpoint = await _unitOfWork.WalletRepository.GetExternalEndpoint(context.Arguments.ExternalEndpointId);
if (externalEndpoint.Endpoint.Equals(_ownEndpoint.ToString()))
{
_logger.LogInformation("Sending to local wallet.");
return await InsertIntoLocalWallet(context, newSlice, externalEndpoint);
}
else
{
_logger.LogInformation("Sending to external wallet.");
return await SendOverRestToExternalWallet(context, newSlice, externalEndpoint);
}
}
Expand All @@ -58,7 +60,7 @@ private async Task<ExecutionResult> SendOverRestToExternalWallet(
{
try
{
_logger.LogDebug("Preparing to send information to receiver");
_logger.LogInformation("Preparing to send information to receiver");

var request = new ReceiveRequest
{
Expand All @@ -81,13 +83,13 @@ private async Task<ExecutionResult> SendOverRestToExternalWallet(
};

var client = new HttpClient();
_logger.LogDebug("Sending information to receiver");
_logger.LogInformation("Sending information to receiver");

var response = await client.PostAsJsonAsync(externalEndpoint.Endpoint, request);
response.EnsureSuccessStatusCode();
await _unitOfWork.TransferRepository.SetTransferredSliceState(newSlice.Id, TransferredSliceState.Transferred);

_logger.LogDebug("Information Sent to receiver");
_logger.LogInformation("Information Sent to receiver");

return context.Completed();
}
Expand All @@ -100,7 +102,7 @@ private async Task<ExecutionResult> SendOverRestToExternalWallet(

private async Task<ExecutionResult> InsertIntoLocalWallet(ExecuteContext<SendInformationToReceiverWalletArgument> context, TransferredSlice newSlice, ExternalEndpoint externalEndpoint)
{
_logger.LogDebug("Receiver is local.");
_logger.LogInformation("Receiver is local.");

var walletEndpoint = await _unitOfWork.WalletRepository.GetWalletEndpoint(externalEndpoint.PublicKey);

Expand Down Expand Up @@ -131,7 +133,7 @@ private async Task<ExecutionResult> InsertIntoLocalWallet(ExecuteContext<SendInf

_unitOfWork.Commit();

_logger.LogDebug("Slice inserted locally into receiver wallet.");
_logger.LogInformation("Slice inserted locally into receiver wallet.");

return context.Completed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public async Task<ExecutionResult> Execute(ExecuteContext<TransferFullSliceArgum
};
await _unitOfWork.TransferRepository.InsertTransferredSlice(transferredSlice);

_logger.LogInformation($"Registering transfer for certificateId {sourceSlice.CertificateId}");

var transferredEvent = CreateTransferEvent(sourceSlice, receiverPublicKey);

Expand Down

0 comments on commit 7b80361

Please sign in to comment.