Skip to content

Commit 4f49e91

Browse files
committed
Removed IStore.ForkTxNonces()
1 parent 21e04f9 commit 4f49e91

File tree

8 files changed

+22
-61
lines changed

8 files changed

+22
-61
lines changed

src/Libplanet.Store/BaseStore.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ public virtual long CountBlocks()
164164
/// <inheritdoc/>
165165
public abstract void Dispose();
166166

167-
/// <inheritdoc/>
168-
public abstract void ForkTxNonces(Guid sourceChainId, Guid destinationChainId);
169-
170167
/// <inheritdoc/>
171168
public abstract void PruneOutdatedChains(bool noopWithoutCanon = false);
172169

src/Libplanet.Store/DefaultStore.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -600,14 +600,6 @@ public override void IncreaseTxNonce(Guid chainId, Address signer, long delta =
600600
collection.Upsert(docId, new BsonDocument() { ["v"] = new BsonValue(nextNonce) });
601601
}
602602

603-
/// <inheritdoc/>
604-
public override void ForkTxNonces(Guid sourceChainId, Guid destinationChainId)
605-
{
606-
LiteCollection<BsonDocument> srcColl = TxNonceCollection(sourceChainId);
607-
LiteCollection<BsonDocument> destColl = TxNonceCollection(destinationChainId);
608-
destColl.InsertBulk(srcColl.FindAll());
609-
}
610-
611603
/// <inheritdoc/>
612604
public override void PruneOutdatedChains(bool noopWithoutCanon = false)
613605
{

src/Libplanet.Store/IStore.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,6 @@ public interface IStore : IDisposable
257257

258258
long CountBlocks();
259259

260-
/// <summary>
261-
/// Forks <see cref="Transaction"/> <see cref="Transaction.Nonce"/>s from
262-
/// <paramref name="sourceChainId"/> to
263-
/// <paramref name="destinationChainId"/>.
264-
/// </summary>
265-
/// <param name="sourceChainId">The chain <see cref="BlockChain.Id"/> of
266-
/// <see cref="Transaction"/> <see cref="Transaction.Nonce"/>s to fork.</param>
267-
/// <param name="destinationChainId">The chain <see cref="BlockChain.Id"/> of destination
268-
/// <see cref="Transaction"/> <see cref="Transaction.Nonce"/>s.</param>
269-
void ForkTxNonces(Guid sourceChainId, Guid destinationChainId);
270-
271260
/// <summary>
272261
/// Delete all non-canonical chains.
273262
/// </summary>

src/Libplanet.Store/MemoryStore.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,6 @@ bool IStore.ContainsTransaction(TxId txId) =>
254254
long IStore.CountBlocks() =>
255255
_blocks.Count;
256256

257-
void IStore.ForkTxNonces(Guid sourceChainId, Guid destinationChainId)
258-
{
259-
if (_txNonces.TryGetValue(sourceChainId, out ConcurrentDictionary<Address, long>? dict))
260-
{
261-
_txNonces[destinationChainId] = new ConcurrentDictionary<Address, long>(dict);
262-
}
263-
}
264-
265257
void IStore.PruneOutdatedChains(bool noopWithoutCanon)
266258
{
267259
if (!(_canonicalChainId is { } ccid))

test/Libplanet.RocksDBStore.Tests/RocksDBStoreTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,27 @@ public void PruneOutdatedChains()
324324
store.IterateIndexes(cid3, 0, null));
325325
Assert.Equal(3, store.CountIndex(cid3));
326326
}
327+
328+
[SkippableFact]
329+
public void ForkTxNonces()
330+
{
331+
var path = Path.Combine(Path.GetTempPath(), $"rocksdb_test_{Guid.NewGuid()}");
332+
var store = new RocksDBStore(path);
333+
Guid sourceChainId = Guid.NewGuid();
334+
Guid destinationChainId = Guid.NewGuid();
335+
store.IncreaseTxNonce(sourceChainId, Fx.Address1, 1);
336+
store.IncreaseTxNonce(sourceChainId, Fx.Address2, 2);
337+
store.IncreaseTxNonce(sourceChainId, Fx.Address3, 3);
338+
339+
store.ForkTxNonces(sourceChainId, destinationChainId);
340+
341+
Assert.Equal(1, store.GetTxNonce(destinationChainId, Fx.Address1));
342+
Assert.Equal(2, store.GetTxNonce(destinationChainId, Fx.Address2));
343+
Assert.Equal(3, store.GetTxNonce(destinationChainId, Fx.Address3));
344+
345+
store.IncreaseTxNonce(sourceChainId, Fx.Address1, 1);
346+
Assert.Equal(2, store.GetTxNonce(sourceChainId, Fx.Address1));
347+
Assert.Equal(1, store.GetTxNonce(destinationChainId, Fx.Address1));
348+
}
327349
}
328350
}

test/Libplanet.Tests/Store/ProxyStore.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ public virtual bool ContainsTransaction(TxId txId) =>
151151
public virtual long CountBlocks() =>
152152
Store.CountBlocks();
153153

154-
/// <inheritdoc cref="IStore.ForkTxNonces(Guid, Guid)"/>
155-
public virtual void ForkTxNonces(Guid sourceChainId, Guid destinationChainId) =>
156-
Store.ForkTxNonces(sourceChainId, destinationChainId);
157-
158154
/// <inheritdoc cref="IStore.PruneOutdatedChains(bool)"/>
159155
public void PruneOutdatedChains(bool noopWithoutCanon = false) =>
160156
Store.PruneOutdatedChains(noopWithoutCanon);

test/Libplanet.Tests/Store/StoreTest.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -901,27 +901,6 @@ public void ManipulateCommittedEvidence()
901901
}
902902
}
903903

904-
[SkippableFact]
905-
public void ForkTxNonces()
906-
{
907-
IStore store = Fx.Store;
908-
Guid sourceChainId = Guid.NewGuid();
909-
Guid destinationChainId = Guid.NewGuid();
910-
store.IncreaseTxNonce(sourceChainId, Fx.Address1, 1);
911-
store.IncreaseTxNonce(sourceChainId, Fx.Address2, 2);
912-
store.IncreaseTxNonce(sourceChainId, Fx.Address3, 3);
913-
914-
store.ForkTxNonces(sourceChainId, destinationChainId);
915-
916-
Assert.Equal(1, store.GetTxNonce(destinationChainId, Fx.Address1));
917-
Assert.Equal(2, store.GetTxNonce(destinationChainId, Fx.Address2));
918-
Assert.Equal(3, store.GetTxNonce(destinationChainId, Fx.Address3));
919-
920-
store.IncreaseTxNonce(sourceChainId, Fx.Address1, 1);
921-
Assert.Equal(2, store.GetTxNonce(sourceChainId, Fx.Address1));
922-
Assert.Equal(1, store.GetTxNonce(destinationChainId, Fx.Address1));
923-
}
924-
925904
[SkippableFact]
926905
public void IdempotentDispose()
927906
{

test/Libplanet.Tests/Store/StoreTracker.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@ public void IncreaseTxNonce(Guid chainId, Address address, long delta = 1)
174174
_store.IncreaseTxNonce(chainId, address, delta);
175175
}
176176

177-
public void ForkTxNonces(Guid sourceChainId, Guid destinationChainId)
178-
{
179-
Log(nameof(ForkTxNonces), sourceChainId, destinationChainId);
180-
_store.ForkTxNonces(sourceChainId, destinationChainId);
181-
}
182-
183177
public void PruneOutdatedChains(bool noopWithoutCanon = false)
184178
{
185179
Log(nameof(PruneOutdatedChains));

0 commit comments

Comments
 (0)