-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to allow multiple blockchains to be indexed at once
- Loading branch information
1 parent
109a828
commit 9688f30
Showing
28 changed files
with
220 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Infrastructure/Kujira/TransactionListener/KujiraTransactionEnumerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.Extensions.Logging; | ||
using TerraDotnet; | ||
using TerraDotnet.TerraLcd; | ||
|
||
namespace SapientFi.Infrastructure.Kujira.TransactionListener; | ||
|
||
public class KujiraTransactionEnumerator : CosmosTransactionEnumerator<KujiraMarker> | ||
{ | ||
public KujiraTransactionEnumerator( | ||
ILogger<CosmosTransactionEnumerator<KujiraMarker>> logger, | ||
ICosmosLcdApiClient<KujiraMarker> cosmosClient | ||
) : base(logger, | ||
cosmosClient, | ||
new() | ||
{ | ||
SecondsPerBlock = 6, | ||
WindowBlockWidth = 2000, | ||
PaginationLimit = 200 | ||
} | ||
) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
src/Infrastructure/Terra2/BusMessages/RawTerra2TransactionAvailableAnnouncement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
using SapientFi.Infrastructure.Cosmos.BusMessages; | ||
|
||
namespace SapientFi.Infrastructure.Terra2.BusMessages; | ||
|
||
public class RawTerra2TransactionAvailableAnnouncement | ||
public class RawTerra2TransactionAvailableAnnouncement : IRawCosmosTransactionAvailableAnnouncement | ||
{ | ||
public string TransactionHash { get; set; } = string.Empty; | ||
|
||
public long RawEntityId { get; set; } | ||
public string TransactionHash { get; init; } = string.Empty; | ||
public long RawEntityId { get; init; } | ||
} |
61 changes: 3 additions & 58 deletions
61
src/Infrastructure/Terra2/Indexers/Delegations/Storage/Terra2DelegationsRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,11 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using SapientFi.Infrastructure.Cosmos.Indexers.Delegations.Storage; | ||
using ServiceStack.Data; | ||
using ServiceStack.OrmLite; | ||
|
||
namespace SapientFi.Infrastructure.Terra2.Indexers.Delegations.Storage; | ||
|
||
public class Terra2DelegationsRepository | ||
public class Terra2DelegationsRepository : CosmosDelegationsRepository<Terra2ValidatorDelegationLedgerEntity> | ||
{ | ||
private readonly IDbConnectionFactory _dbFactory; | ||
|
||
public Terra2DelegationsRepository(IDbConnectionFactory dbFactory) | ||
{ | ||
_dbFactory = dbFactory; | ||
} | ||
|
||
public virtual async Task SaveAsync(Terra2ValidatorDelegationLedgerEntity entity, CancellationToken cancellationToken = default) | ||
{ | ||
using var db = await _dbFactory.OpenDbConnectionAsync(cancellationToken); | ||
await db.SaveAsync(entity, token: cancellationToken); | ||
} | ||
|
||
public virtual async Task SaveAllAsync(IEnumerable<Terra2ValidatorDelegationLedgerEntity> entities, CancellationToken cancellationToken = default) | ||
{ | ||
using var db = await _dbFactory.OpenDbConnectionAsync(cancellationToken); | ||
await db.SaveAllAsync(entities, token: cancellationToken); | ||
} | ||
|
||
public virtual async Task<T1> SingleAsync<T1, T2>(SqlExpression<T2> sql, CancellationToken ct = default) | ||
{ | ||
using var db = await _dbFactory.OpenDbConnectionAsync(ct); | ||
return await db.SingleAsync<T1>(sql, ct); | ||
} | ||
|
||
public virtual async Task<IEnumerable<T1>> SelectAsync<T1, T2>(SqlExpression<T2> sql, CancellationToken ct = default) | ||
{ | ||
using var db = await _dbFactory.OpenDbConnectionAsync(ct); | ||
return await db.SelectAsync<T1>(sql, ct); | ||
} | ||
|
||
public virtual async Task<T1> SingleByIdAsync<T1, T2>(T2 id, CancellationToken ct = default) | ||
{ | ||
using var db = await _dbFactory.OpenDbConnectionAsync(ct); | ||
return await db.SingleByIdAsync<T1>(id, ct); | ||
} | ||
|
||
public virtual async Task<List<T>> SelectByIds<T>(IEnumerable ids, CancellationToken ct = default) | ||
{ | ||
using var db = await _dbFactory.OpenDbConnectionAsync(ct); | ||
return await db.SelectByIdsAsync<T>(ids, ct); | ||
} | ||
|
||
public virtual async Task<T1> ScalarAsync<T1, T2>(SqlExpression<T2> sql, CancellationToken ct = default) | ||
{ | ||
using var db = await _dbFactory.OpenDbConnectionAsync(ct); | ||
return await db.ScalarAsync<T1>(sql, ct); | ||
} | ||
|
||
public virtual async Task<IDbConnection> GetDbConnectionAsync(CancellationToken cancellationToken = new()) | ||
public Terra2DelegationsRepository(IDbConnectionFactory dbFactory) : base(dbFactory) | ||
{ | ||
return await _dbFactory.OpenDbConnectionAsync(cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Infrastructure/Terra2/Indexers/Delegations/Terra2DelegationIndexer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.Extensions.Logging; | ||
using SapientFi.Infrastructure.Cosmos.Indexers.Delegations; | ||
using SapientFi.Infrastructure.Indexing; | ||
using SapientFi.Infrastructure.Terra2.BusMessages; | ||
using SapientFi.Infrastructure.Terra2.Indexers.Delegations.Storage; | ||
using SapientFi.Infrastructure.Terra2.Storage; | ||
using SapientFi.Kernel.IdGeneration; | ||
|
||
namespace SapientFi.Infrastructure.Terra2.Indexers.Delegations; | ||
|
||
public class Terra2DelegationIndexer | ||
: CosmosDelegationIndexer< | ||
RawTerra2TransactionAvailableAnnouncement, | ||
Terra2ValidatorDelegationLedgerEntity, | ||
Terra2RawTransactionEntity>, | ||
IIndexer<RawTerra2TransactionAvailableAnnouncement> | ||
{ | ||
public Terra2DelegationIndexer( | ||
ILogger<Terra2DelegationIndexer> logger, | ||
Terra2DelegationsRepository repository, | ||
Terra2RawRepository rawRepository, | ||
IdProvider idProvider | ||
) : base(logger, repository, rawRepository, idProvider) | ||
{ | ||
} | ||
public override string NameOfBlockChain => "Terra2"; | ||
public override string Id => "terra2_delegations"; | ||
public override string DisplayName => "Terra2 Delegations"; | ||
} |
Oops, something went wrong.