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

Replace function exceptwith and unionwith with faster functions #1174

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
36c1d16
Merge pull request #1 from neo-project/master
Qiao-Jin Oct 22, 2019
b7f9c02
Replace ExceptWith & UnionWith with equal but faster functionality
Oct 22, 2019
318c99f
Optimization
shargon Oct 22, 2019
0d6b842
Merge branch 'master' into replace-func-exceptwith-unionwith
shargon Oct 22, 2019
af23059
Optimization
shargon Oct 22, 2019
82930da
Optimize remove
shargon Oct 22, 2019
54d2af8
Update neo/Network/P2P/TaskManager.cs
Qiao-Jin Oct 23, 2019
a745880
Code optimization
Oct 23, 2019
e0f9145
Merge branch 'replace-func-exceptwith-unionwith' into review
Qiao-Jin Oct 23, 2019
a84eff9
Update Helper.cs
Qiao-Jin Oct 23, 2019
dd36f20
Merge pull request #2 from shargon/review
Qiao-Jin Oct 23, 2019
089b935
Small change
shargon Oct 23, 2019
a571c22
Optimization
shargon Oct 23, 2019
4381b4c
Update Helper.cs
shargon Oct 23, 2019
dd4a435
Revert
shargon Oct 23, 2019
95136ed
Optimization
shargon Oct 23, 2019
edc0333
Optimize FIFOSet
shargon Oct 23, 2019
4ddc299
Rename
shargon Oct 23, 2019
6da2fc2
Inline
shargon Oct 23, 2019
bcf1c62
Merge pull request #4 from shargon/optimization
Qiao-Jin Oct 23, 2019
88753a6
Update UT_FIFOSet.cs
shargon Oct 23, 2019
59ee120
Fix
shargon Oct 23, 2019
921a343
Update UT_FIFOSet.cs
shargon Oct 23, 2019
621c4e3
Update FIFOSet.cs
shargon Oct 23, 2019
051b7c1
Update FIFOSet.cs
shargon Oct 23, 2019
96418c4
Merge branch 'master' into replace-func-exceptwith-unionwith
vncoelho Oct 23, 2019
f325f96
Merge branch 'master' into replace-func-exceptwith-unionwith
Qiao-Jin Oct 28, 2019
b1f5914
Merge branch 'master' into replace-func-exceptwith-unionwith
erikzhang Oct 30, 2019
f1cef96
Revert FIFOSet
erikzhang Oct 30, 2019
2e704e6
Update Helper.cs
erikzhang Oct 30, 2019
12aa262
Optimize
erikzhang Oct 30, 2019
9b71d5f
Merge branch 'master' into replace-func-exceptwith-unionwith
vncoelho Oct 30, 2019
b23244f
Merge branch 'master' into replace-func-exceptwith-unionwith
vncoelho Oct 30, 2019
360f20a
Reverting independet byte checks to SequenceEqual
vncoelho Oct 31, 2019
ec2bfd7
Merge branch 'master' into replace-func-exceptwith-unionwith
vncoelho Oct 31, 2019
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
9 changes: 7 additions & 2 deletions neo/Network/P2P/Payloads/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,13 @@ public override int GetHashCode()

public UInt160[] GetScriptHashesForVerifying(Snapshot snapshot)
{
var hashes = new HashSet<UInt160> { Sender };
hashes.UnionWith(Cosigners.Select(p => p.Account));
if (Cosigners.Length == 0 || (Cosigners.Length == 1 && Cosigners[0].Account == Sender))
{
return new UInt160[] { Sender };
}

var hashes = new HashSet<UInt160>(Cosigners.Select(p => p.Account));
hashes.UnionWith(new HashSet<UInt160> { Sender });
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
return hashes.OrderBy(p => p).ToArray();
shargon marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
6 changes: 3 additions & 3 deletions neo/Network/P2P/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ private void OnNewTasks(InvPayload payload)
return;
}
HashSet<UInt256> hashes = new HashSet<UInt256>(payload.Hashes);
hashes.ExceptWith(knownHashes);
hashes.RemoveWhere(q => knownHashes.Contains(q));
if (payload.Type == InventoryType.Block)
session.AvailableTasks.UnionWith(hashes.Where(p => globalTasks.ContainsKey(p)));

hashes.ExceptWith(globalTasks.Keys);
hashes.RemoveWhere(q => globalTasks.Keys.Contains(q));
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
Qiao-Jin marked this conversation as resolved.
Show resolved Hide resolved
if (hashes.Count == 0)
{
RequestTasks(session);
Expand Down Expand Up @@ -203,7 +203,7 @@ private void RequestTasks(TaskSession session)
if (session.HasTask) return;
if (session.AvailableTasks.Count > 0)
{
session.AvailableTasks.ExceptWith(knownHashes);
session.AvailableTasks.RemoveWhere(q => knownHashes.Contains(q));
session.AvailableTasks.RemoveWhere(p => Blockchain.Singleton.ContainsBlock(p));
HashSet<UInt256> hashes = new HashSet<UInt256>(session.AvailableTasks);
if (hashes.Count > 0)
Expand Down