-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
652ba8f
commit cc05f77
Showing
10 changed files
with
305 additions
and
48 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 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
12 changes: 12 additions & 0 deletions
12
sdk/node/Libplanet.Node/Services/Renderer/IRenderObservables.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,12 @@ | ||
namespace Libplanet.Node.Services.Renderer; | ||
|
||
public interface IRenderObservables | ||
{ | ||
public RenderActionObservable RenderActionObservable { get; } | ||
|
||
public RenderActionErrorObservable RenderActionErrorObservable { get; } | ||
|
||
public RenderBlockObservable RenderBlockObservable { get; } | ||
|
||
public RenderBlockEndObservable RenderBlockEndObservable { get; } | ||
} |
65 changes: 65 additions & 0 deletions
65
sdk/node/Libplanet.Node/Services/Renderer/RenderActionErrorObservable.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,65 @@ | ||
using System.Security.Cryptography; | ||
using Bencodex.Types; | ||
using Libplanet.Action; | ||
using Libplanet.Blockchain.Renderers; | ||
using Libplanet.Common; | ||
using Libplanet.Types.Blocks; | ||
using R3; | ||
using Output = ( | ||
Bencodex.Types.IValue, | ||
Libplanet.Action.ICommittedActionContext, | ||
System.Exception); | ||
|
||
namespace Libplanet.Node.Services.Renderer; | ||
|
||
public class RenderActionErrorObservable : IObservable<Output>, IActionRenderer, IDisposable | ||
{ | ||
private readonly List<IObserver<Output>> _observers = []; | ||
private readonly BooleanDisposable _disposable = new BooleanDisposable(); | ||
|
||
public IDisposable Subscribe(IObserver<Output> observer) | ||
{ | ||
_observers.Add(observer); | ||
return _disposable; | ||
} | ||
|
||
public void RenderBlock(Block oldTip, Block newTip) | ||
{ | ||
} | ||
|
||
public void RenderAction( | ||
IValue action, | ||
ICommittedActionContext context, | ||
HashDigest<SHA256> nextState) | ||
{ | ||
} | ||
|
||
public void RenderActionError(IValue action, ICommittedActionContext context, Exception exception) | ||
{ | ||
if (_disposable.IsDisposed) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (IObserver<Output> observer in _observers) | ||
{ | ||
observer.OnNext((action, context, exception)); | ||
} | ||
} | ||
|
||
public void RenderBlockEnd(Block oldTip, Block newTip) | ||
{ | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_disposable.Dispose(); | ||
|
||
foreach (IObserver<Output> observer in _observers) | ||
{ | ||
observer.OnCompleted(); | ||
} | ||
|
||
GC.SuppressFinalize(this); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
sdk/node/Libplanet.Node/Services/Renderer/RenderActionObservable.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,64 @@ | ||
using System.Security.Cryptography; | ||
using Bencodex.Types; | ||
using Libplanet.Action; | ||
using Libplanet.Blockchain.Renderers; | ||
using Libplanet.Common; | ||
using Libplanet.Types.Blocks; | ||
using R3; | ||
using Output = ( | ||
Bencodex.Types.IValue, | ||
Libplanet.Action.ICommittedActionContext, | ||
Libplanet.Common.HashDigest<System.Security.Cryptography.SHA256>); | ||
|
||
namespace Libplanet.Node.Services.Renderer; | ||
|
||
public class RenderActionObservable : IObservable<Output>, IActionRenderer, IDisposable | ||
{ | ||
private readonly List<IObserver<Output>> _observers = []; | ||
private readonly BooleanDisposable _disposable = new BooleanDisposable(); | ||
|
||
public IDisposable Subscribe(IObserver<Output> observer) | ||
{ | ||
_observers.Add(observer); | ||
return _disposable; | ||
} | ||
|
||
public void RenderBlock(Block oldTip, Block newTip) | ||
{ | ||
} | ||
|
||
public void RenderAction( | ||
IValue action, | ||
ICommittedActionContext context, | ||
HashDigest<SHA256> nextState) | ||
{ | ||
if (_disposable.IsDisposed) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (IObserver<Output> observer in _observers) | ||
{ | ||
observer.OnNext((action, context, nextState)); | ||
} | ||
} | ||
|
||
public void RenderActionError(IValue action, ICommittedActionContext context, Exception exception) | ||
{ | ||
} | ||
|
||
public void RenderBlockEnd(Block oldTip, Block newTip) | ||
{ | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_disposable.Dispose(); | ||
foreach (IObserver<Output> observer in _observers) | ||
{ | ||
observer.OnCompleted(); | ||
} | ||
|
||
GC.SuppressFinalize(this); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
sdk/node/Libplanet.Node/Services/Renderer/RenderBlockEndObservable.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,65 @@ | ||
using System.Security.Cryptography; | ||
using Bencodex.Types; | ||
using Libplanet.Action; | ||
using Libplanet.Blockchain.Renderers; | ||
using Libplanet.Common; | ||
using Libplanet.Types.Blocks; | ||
using R3; | ||
|
||
namespace Libplanet.Node.Services.Renderer; | ||
|
||
public class RenderBlockEndObservable : IObservable<(Block, Block)>, IActionRenderer, IDisposable | ||
{ | ||
private readonly List<IObserver<(Block, Block)>> _observers | ||
= new List<IObserver<(Block, Block)>>(); | ||
|
||
private readonly BooleanDisposable _disposable = new BooleanDisposable(); | ||
|
||
public IDisposable Subscribe(IObserver<(Block, Block)> observer) | ||
{ | ||
_observers.Add(observer); | ||
return _disposable; | ||
} | ||
|
||
public void RenderBlock(Block oldTip, Block newTip) | ||
{ | ||
} | ||
|
||
public void RenderAction( | ||
IValue action, | ||
ICommittedActionContext context, | ||
HashDigest<SHA256> nextState) | ||
{ | ||
} | ||
|
||
public void RenderActionError( | ||
IValue action, | ||
ICommittedActionContext context, | ||
Exception exception) | ||
{ | ||
} | ||
|
||
public void RenderBlockEnd(Block oldTip, Block newTip) | ||
{ | ||
if (_disposable.IsDisposed) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (IObserver<(Block, Block)> observer in _observers) | ||
{ | ||
observer.OnNext((oldTip, newTip)); | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_disposable.Dispose(); | ||
foreach (IObserver<(Block, Block)> observer in _observers) | ||
{ | ||
observer.OnCompleted(); | ||
} | ||
|
||
GC.SuppressFinalize(this); | ||
} | ||
} |
Oops, something went wrong.