Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Data/Repositories/Interfaces/INodeRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace NodeGuard.Data.Repositories.Interfaces;

public interface INodeRepository
{
Task<Node?> GetById(int id);
Task<Node?> GetById(int id, bool includeRelatedData = true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document?


Task<Node?> GetByPubkey(string key);

Expand Down
22 changes: 14 additions & 8 deletions src/Data/Repositories/NodeRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,23 @@ public NodeRepository(IRepository<Node> repository,
_mapper = mapper;
}

public async Task<Node?> GetById(int id)
public async Task<Node?> GetById(int id, bool includeRelatedData = true)
{
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();

return await applicationDbContext.Nodes
.Include(node => node.Users)
.ThenInclude(user => user.Keys)
.ThenInclude(key => key.Wallets)
.Include(x => x.FundsDestinationWallet)
.ThenInclude(x => x.Keys)
.SingleOrDefaultAsync(x => x.Id == id);
var query = applicationDbContext.Nodes.AsQueryable();

if (includeRelatedData)
{
query = query
.Include(node => node.Users)
.ThenInclude(user => user.Keys)
.ThenInclude(key => key.Wallets)
.Include(x => x.FundsDestinationWallet)
.ThenInclude(x => x.Keys);
}

return await query.SingleOrDefaultAsync(x => x.Id == id);
}

public async Task<Node?> GetByPubkey(string key)
Expand Down
4 changes: 2 additions & 2 deletions src/Jobs/NodeHtlcSubscribeJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task Execute(IJobExecutionContext context)

try
{
var node = await _nodeRepository.GetById(nodeId);
var node = await _nodeRepository.GetById(nodeId, false);
if (!IsNodeEligible(node))
{
_logger.LogInformation("Node {NodeId} is not eligible for HTLC monitoring", nodeId);
Expand All @@ -80,7 +80,7 @@ public async Task Execute(IJobExecutionContext context)
var stream = _lightningRouterService.SubscribeHtlcEvents(node!);
while (await stream.ResponseStream.MoveNext(context.CancellationToken))
{
node = await _nodeRepository.GetById(nodeId);
node = await _nodeRepository.GetById(nodeId, false);

try
{
Expand Down
Loading