-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Libplanet.Node.Services.Renderer; | ||
|
||
public interface IRenderObservables | ||
{ | ||
public RenderActionObservable RenderActionObservable { get; } | ||
|
||
public RenderActionErrorObservable RenderActionErrorObservable { get; } | ||
|
||
public RenderBlockObservable RenderBlockObservable { get; } | ||
|
||
public RenderBlockEndObservable RenderBlockEndObservable { get; } | ||
} | ||
Check warning on line 12 in sdk/node/Libplanet.Node/Services/Renderer/IRenderObservables.cs
|
||
|
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) | ||
Check warning on line 37 in sdk/node/Libplanet.Node/Services/Renderer/RenderActionErrorObservable.cs
|
||
{ | ||
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); | ||
} | ||
} |
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) | ||
Check warning on line 46 in sdk/node/Libplanet.Node/Services/Renderer/RenderActionObservable.cs
|
||
{ | ||
} | ||
|
||
public void RenderBlockEnd(Block oldTip, Block newTip) | ||
{ | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_disposable.Dispose(); | ||
foreach (IObserver<Output> observer in _observers) | ||
{ | ||
observer.OnCompleted(); | ||
} | ||
|
||
GC.SuppressFinalize(this); | ||
} | ||
} |
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); | ||
} | ||
} |