Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
@@ -0,0 +1,22 @@
using NBitcoin;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
/// <summary>
/// Tracks changes made to objects.
/// </summary>
public interface IChangeTracker
{
/// <summary>
/// Records the object (or part of the object) that was originally read from the database.
/// </summary>
/// <param name="obj">The object to record the original value of.</param>
void RecordOldValue(IBitcoinSerializable obj);

/// <summary>
/// Instructs the object to record its original value (or part thereof). Typically called after reading it from the database.
/// </summary>
/// <param name="obj">The object being instructed to record its original value.</param>
void SetOldValue(IBitcoinSerializable obj);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using Stratis.FederatedPeg.Features.FederationGateway.TargetChain;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
public interface ICrossChainDB : ICrossChainLookups, IDisposable
{
/// <summary>Initializes the cross-chain-transfer store.</summary>
void Initialize();

/// <summary>
/// Creates a <see cref="CrossChainDBTransaction"/> for either read or read/write operations.
/// </summary>
/// <param name="mode">The mode which is either <see cref="CrossChainDBTransactionMode.Read"/>
/// or <see cref="CrossChainDBTransactionMode.ReadWrite"/></param>
/// <returns>The <see cref="CrossChainDBTransaction"/> object.</returns>
CrossChainDBTransaction GetTransaction(CrossChainDBTransactionMode mode = CrossChainDBTransactionMode.Read);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public interface ICrossChainTransfer : IBitcoinSerializable
int? BlockHeight { get; }

CrossChainTransferStatus Status { get; }
CrossChainTransferStatus? DbStatus { get; }

/// <summary>
/// Depending on the status some fields can't be null.
Expand Down Expand Up @@ -82,7 +83,14 @@ public interface ICrossChainTransfer : IBitcoinSerializable
/// <summary>
/// Gets the number of sigatures in the first input of the transaction.
/// </summary>
/// <param name="network">The network associated with the transfer's partial transaction.</param>
/// <returns>Number of signatures.</returns>
int GetSignatureCount(Network network);

/// <summary>
/// Used by the store to note down the status as recorded in the database.
/// This allows the store to update its internal deposit-by-status lookup.
/// </summary>
void RecordDbStatus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
using System.Threading.Tasks;
using NBitcoin;
using Stratis.FederatedPeg.Features.FederationGateway.Models;
using Stratis.FederatedPeg.Features.FederationGateway.TargetChain;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
/// <summary>Interface for interacting with the cross-chain transfer database.</summary>
public interface ICrossChainTransferStore : IDisposable
public interface ICrossChainTransferStore : IDisposable, ICrossChainDB
{
/// <summary>Initializes the cross-chain-transfer store.</summary>
void Initialize();

/// <summary>Starts the cross-chain-transfer store.</summary>
void Start();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
/// <summary>
/// Provides methods for creating trackers and for updating lookups based on
/// the information contained in the trackers.
/// </summary>
public interface ICrossChainLookups
{
/// <summary>
/// Creates trackers for recording information on how to update the lookups.
/// </summary>
/// <returns>Trackers for recording information on how to update the lookups.</returns>
Dictionary<string, IChangeTracker> CreateTrackers();

/// <summary>
/// Updates lookups based on the changes recorded in the tracker object.
/// </summary>
/// <param name="trackers">Trackers recording information about how to update the lookups.</param>
/// <remarks>This method is intended be called by the <see cref="CrossChainDBTransaction"/> class.</remarks>
void UpdateLookups(Dictionary<string, IChangeTracker> trackers);
}
}
Loading