From 8fe0e577448fdfe3a9fd2320d6a6bb8c4f3c62fd Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Tue, 23 Feb 2021 12:08:26 +0900 Subject: [PATCH 1/3] Fix NotifyAction subscribe --- .../Controllers/GraphQLController.cs | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/NineChronicles.Headless/Controllers/GraphQLController.cs b/NineChronicles.Headless/Controllers/GraphQLController.cs index fd9431718..ff4fd5a82 100644 --- a/NineChronicles.Headless/Controllers/GraphQLController.cs +++ b/NineChronicles.Headless/Controllers/GraphQLController.cs @@ -32,7 +32,6 @@ public class GraphQLController : ControllerBase private ConcurrentDictionary NotificationRecords { get; } = new ConcurrentDictionary(); private StandaloneContext StandaloneContext { get; } - private Address _address; public const string RunStandaloneEndpoint = "/run-standalone"; @@ -115,9 +114,8 @@ public IActionResult SetPrivateKey([FromBody] SetPrivateKeyRequest request) var privateKey = new PrivateKey(ByteUtil.ParseHex(request.PrivateKeyString)); StandaloneContext.NineChroniclesNodeService.PrivateKey = privateKey; - _address = privateKey.PublicKey.ToAddress(); - var msg = $"Private key set ({privateKey.PublicKey.ToAddress()})."; - Log.Debug(msg); + var msg = $"Private key set ({StandaloneContext.NineChroniclesNodeService.PrivateKey.PublicKey.ToAddress()})."; + Log.Information("SetPrivateKey: {Msg}", msg); return Ok(msg); } @@ -249,34 +247,40 @@ bool NeedsRefillNotification(AvatarState avatarState) private void NotifyAction(ActionBase.ActionEvaluation eval) { - if (eval.OutputStates.UpdatedAddresses.Contains(_address)) + if (StandaloneContext.NineChroniclesNodeService.PrivateKey is null) { - if (eval.Signer == _address) + return; + } + var address = StandaloneContext.NineChroniclesNodeService.PrivateKey.PublicKey.ToAddress(); + if (eval.OutputStates.UpdatedAddresses.Contains(address) || eval.Signer == address) + { + if (eval.Signer == address) { var type = NotificationEnum.Refill; var msg = string.Empty; switch (eval.Action) { - case HackAndSlash3 has: + case HackAndSlash4 has: type = NotificationEnum.HAS; msg = has.stageId.ToString(CultureInfo.InvariantCulture); break; - case CombinationConsumable2 _: + case CombinationConsumable3 _: type = NotificationEnum.CombinationConsumable; break; - case CombinationEquipment3 _: + case CombinationEquipment4 _: type = NotificationEnum.CombinationEquipment; break; - case Buy3 _: + case Buy4 _: type = NotificationEnum.Buyer; break; } + Log.Information("NotifyAction: Type: {Type} MSG: {Msg}", type, msg); var notification = new Notification(type, msg); StandaloneContext.NotificationSubject.OnNext(notification); } else { - if (eval.Action is Buy3 buy && buy.sellerAgentAddress == _address) + if (eval.Action is Buy4 buy && buy.sellerAgentAddress == address) { var notification = new Notification(NotificationEnum.Seller); StandaloneContext.NotificationSubject.OnNext(notification); From d1d4e9fd72d4789c2c01cfe515f2a733b0bdcd89 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Tue, 23 Feb 2021 14:10:45 +0900 Subject: [PATCH 2/3] Review applied. --- NineChronicles.Headless/Controllers/GraphQLController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NineChronicles.Headless/Controllers/GraphQLController.cs b/NineChronicles.Headless/Controllers/GraphQLController.cs index ff4fd5a82..19e33ca9b 100644 --- a/NineChronicles.Headless/Controllers/GraphQLController.cs +++ b/NineChronicles.Headless/Controllers/GraphQLController.cs @@ -249,9 +249,10 @@ private void NotifyAction(ActionBase.ActionEvaluation eval) { if (StandaloneContext.NineChroniclesNodeService.PrivateKey is null) { + Log.Information("PrivateKey is not set. please call SetPrivateKey() first."); return; } - var address = StandaloneContext.NineChroniclesNodeService.PrivateKey.PublicKey.ToAddress(); + Address address = StandaloneContext.NineChroniclesNodeService.PrivateKey.PublicKey.ToAddress(); if (eval.OutputStates.UpdatedAddresses.Contains(address) || eval.Signer == address) { if (eval.Signer == address) From ebe304d1cc7798a6909653902fd8a5371b3a252b Mon Sep 17 00:00:00 2001 From: Kidon Seo Date: Wed, 24 Feb 2021 18:25:37 +0900 Subject: [PATCH 3/3] update docker workflow --- .github/workflows/push_docker_image.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push_docker_image.yml b/.github/workflows/push_docker_image.yml index 7243e84e9..5fefe001c 100644 --- a/.github/workflows/push_docker_image.yml +++ b/.github/workflows/push_docker_image.yml @@ -5,6 +5,7 @@ on: branches: - main - 9c-main + - development jobs: build_and_push: @@ -17,7 +18,7 @@ jobs: - name: login run: docker login --username '${{ secrets.DOCKER_USERNAME }}' --password '${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}' - name: build - run: docker build . -t planetariumhq/ninechronicles-headless:git-${{ github.sha }} --build-arg COMMIT=git-${{ github.sha }} --build-arg COMMIT=git-${{ github.sha }} + run: docker build . -t planetariumhq/ninechronicles-headless:git-${{ github.sha }} --build-arg COMMIT=git-${{ github.sha }} - name: push git-version run: docker push planetariumhq/ninechronicles-headless:git-${{ github.sha }}