Skip to content

Commit

Permalink
change query
Browse files Browse the repository at this point in the history
  • Loading branch information
boscohyun committed May 10, 2024
1 parent d648260 commit 5f69cd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
21 changes: 11 additions & 10 deletions Mimir.Worker/BlockPoller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,29 @@ private async Task EveryAvatarAsync(
StateGetter stateGetter,
CancellationToken cancellationToken)
{
var operationResult = await headlessGqlClient.GetTransactions.ExecuteAsync(cancellationToken);
var operationResult = await headlessGqlClient.GetTransactionSigners.ExecuteAsync(
processBlockIndex,
cancellationToken);
if (operationResult.Data is null)
{
HandleErrors(operationResult);
return;
}

if (operationResult.Data.ChainQuery.BlockQuery is null ||
operationResult.Data.ChainQuery.BlockQuery.Blocks.Count == 0)
var txs = operationResult.Data.Transaction.NcTransactions;
if (txs is null || txs.Count == 0)
{
return;
}

var block = operationResult.Data.ChainQuery.BlockQuery.Blocks[0];
if (block.Index < processBlockIndex)
foreach (var tx in txs)
{
return;
}
if (tx is null)
{
continue;
}

foreach (var transaction in block.Transactions)
{
var agentAddress = new Address(transaction.Signer);
var agentAddress = new Address(tx.Signer);
var avatarAddresses = Enumerable.Range(0, GameConfig.SlotCount)
.Select(e => Addresses.GetAvatarAddress(agentAddress, e));
var avatarDataArray = await Task.WhenAll(avatarAddresses.Select(stateGetter.GetAvatarData));
Expand Down
13 changes: 4 additions & 9 deletions Mimir.Worker/Queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ query GetBattleArenaTransactions($blockIndex: Long!) {
}
}

query GetTransactions {
chainQuery {
blockQuery {
blocks(desc: true, limit: 1) {
index
transactions {
signer
}
}
query GetTransactionSigners($blockIndex: Long!) {
transaction {
ncTransactions(startingBlockIndex: $blockIndex, limit: 1, actionType: "^[a-zA-Z0-9]*$") {
signer
}
}
}

0 comments on commit 5f69cd2

Please sign in to comment.