Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust mysql schema #21

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public HackAndSlashType()
Field(x => x.Avatar_Address);
Field(x => x.Stage_Id);
Field(x => x.Cleared);
Field(x => x.Block_Hash);

Name = "HackAndSlash";
}
Expand Down
5 changes: 4 additions & 1 deletion NineChronicles.DataProvider/RenderSubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Reactive;
Copy link
Member

Choose a reason for hiding this comment

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

Is this using needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I must've left it when trying other things 😅. It's been removed now, thank you for checking!


namespace NineChronicles.DataProvider
{
using System;
Expand Down Expand Up @@ -53,7 +55,8 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
ev.Signer.ToString(),
action.avatarAddress.ToString(),
action.stageId,
action.Result.IsClear
action.Result.IsClear,
ev.BlockHash.ToString()
);
Log.Debug("Stored HackAndSlash action in block #{0}", ev.BlockIndex);
}
Expand Down
2 changes: 2 additions & 0 deletions NineChronicles.DataProvider/Store/Models/HackAndSlashModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public struct HackAndSlashModel
public int Stage_Id { get; set; }

public bool Cleared { get; set; }

public string Block_Hash { get; set; }
}
}
4 changes: 3 additions & 1 deletion NineChronicles.DataProvider/Store/MySqlStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ public void StoreHackAndSlash(
string agentAddress,
string avatarAddress,
int stageId,
bool cleared)
bool cleared,
string blockHash)
{
Insert(HackAndSlashDbName, new Dictionary<string, object>
{
["agent_address"] = agentAddress,
["avatar_address"] = avatarAddress,
["stage_id"] = stageId,
["cleared"] = cleared,
["block_hash"] = blockHash,
});
}

Expand Down
1 change: 1 addition & 0 deletions sql/initialize-database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS `data_provider`.`hack_and_slash` (
`agent_address` VARCHAR NOT NULL,
`stage_id` INT NOT NULL,
`cleared` BOOLEAN NOT NULL,
`block_hash` VARCHAR NOT NULL,

INDEX `fk_hack_and_slash_avatar1_idx` (`avatar_address`),
INDEX `fk_hack_and_slash_agent1_idx` (`agent_address`),
Expand Down