Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcast transaction as soon as new transactions received #496

Merged
merged 3 commits into from Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -57,6 +57,8 @@ To be released.

### Behavioral changes

- `Swarm<T>` now broadcasts transactions as soon as new transactions are received.
[[#463], [#496]]
- `Swarm<T>` now ignores block hashes which already exists. [[#461], [#484]]
- `Swarm<T>.PreloadAsync()` method became to download precalculated states
of blocks from a likely branchpoint instead of a genesis block from
Expand All @@ -82,11 +84,13 @@ To be released.
[#420]: https://github.com/planetarium/libplanet/pull/420
[#450]: https://github.com/planetarium/libplanet/pull/450
[#461]: https://github.com/planetarium/libplanet/issues/461
[#463]: https://github.com/planetarium/libplanet/issues/463
[#470]: https://github.com/planetarium/libplanet/pull/470
[#481]: https://github.com/planetarium/libplanet/pull/481
[#483]: https://github.com/planetarium/libplanet/issues/483
[#484]: https://github.com/planetarium/libplanet/pull/484
[#486]: https://github.com/planetarium/libplanet/pull/486
[#496]: https://github.com/planetarium/libplanet/pull/496
[Kademlia]: https://en.wikipedia.org/wiki/Kademlia


Expand Down
6 changes: 4 additions & 2 deletions Libplanet/Net/Swarm.cs
Expand Up @@ -1607,8 +1607,8 @@ CancellationToken cancellationToken
_logger.Debug("Swapping complete");
}

var msg = new BlockHashes(peer.Address, blocks.Select(b => b.Hash));
BroadcastMessage(msg);
// FIXME: Moved to more appropriate place
BroadcastBlocks(blocks);
}
else
{
Expand Down Expand Up @@ -1744,6 +1744,8 @@ private void TransferTxs(GetTxs getTxs)
_blockChain.StageTransactions(txs.ToImmutableHashSet());
TxReceived.Set();
_logger.Debug("Txs staged successfully.");

BroadcastTxs(txs);
}

private void TransferBlocks(GetBlocks getData)
Expand Down