-
Notifications
You must be signed in to change notification settings - Fork 1k
Neo as dotnet standard #3082
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
Neo as dotnet standard #3082
Changes from 5 commits
30d553f
3cbd2ae
f4ab9ac
9be998a
3343e7a
8be98a2
eae2783
09245cd
ef761da
798b716
48a25e8
7e5798b
e7c66a7
d43ebdf
ed969ba
b2d927a
e75bf25
575dc98
650203f
11f830b
33b3647
9750ddb
c18dea6
ce6aedf
a3cf222
c2e8e57
2ca7628
a390944
85e5f6b
a2665fe
7c67352
7da0534
95835d3
a17e078
85f62af
eb97a1e
28ebae7
dda715d
0e0e2be
aa727a8
eab2466
858e428
ae6075a
74c2c08
354e0c3
1fd95d2
690bd5e
9db4d39
95f2ec6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright (C) 2015-2024 The Neo Project. | ||
| // | ||
| // BigIntegerExtensions.cs file belongs to the neo project and is free | ||
| // software distributed under the MIT software license, see the | ||
| // accompanying file LICENSE in the main directory of the | ||
| // repository or http://www.opensource.org/licenses/mit-license.php | ||
| // for more details. | ||
| // | ||
| // Redistribution and use in source and binary forms with or without | ||
| // modifications are permitted. | ||
|
|
||
| #if !NET5_0_OR_GREATER | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace System.Numerics | ||
| { | ||
| public static class BigIntegerExtensions | ||
| { | ||
| public static int GetBitLength(this BigInteger i) | ||
| { | ||
| byte[] b = i.ToByteArray(); | ||
| return (b.Length - 1) * 8 + BitLen(i.Sign > 0 ? b[b.Length - 1] : 255 - b[b.Length - 1]); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| static int BitLen(int w) | ||
| { | ||
| return (w < 1 << 15 ? (w < 1 << 7 | ||
| ? (w < 1 << 3 ? (w < 1 << 1 | ||
| ? (w < 1 << 0 ? (w < 0 ? 32 : 0) : 1) | ||
| : (w < 1 << 2 ? 2 : 3)) : (w < 1 << 5 | ||
| ? (w < 1 << 4 ? 4 : 5) | ||
| : (w < 1 << 6 ? 6 : 7))) | ||
| : (w < 1 << 11 | ||
| ? (w < 1 << 9 ? (w < 1 << 8 ? 8 : 9) : (w < 1 << 10 ? 10 : 11)) | ||
| : (w < 1 << 13 ? (w < 1 << 12 ? 12 : 13) : (w < 1 << 14 ? 14 : 15)))) : (w < 1 << 23 ? (w < 1 << 19 | ||
| ? (w < 1 << 17 ? (w < 1 << 16 ? 16 : 17) : (w < 1 << 18 ? 18 : 19)) | ||
| : (w < 1 << 21 ? (w < 1 << 20 ? 20 : 21) : (w < 1 << 22 ? 22 : 23))) : (w < 1 << 27 | ||
| ? (w < 1 << 25 ? (w < 1 << 24 ? 24 : 25) : (w < 1 << 26 ? 26 : 27)) | ||
| : (w < 1 << 29 ? (w < 1 << 28 ? 28 : 29) : (w < 1 << 30 ? 30 : 31))))); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,8 +183,8 @@ private static XmlDocument SOAPRequest(string url, string soap, string function) | |
| request.Headers.Add("Content-Type", "text/xml; charset=\"utf-8\""); | ||
| request.Content = new StringContent(req); | ||
| using HttpClient http = new(); | ||
| using HttpResponseMessage response = http.Send(request); | ||
| using Stream stream = response.EnsureSuccessStatusCode().Content.ReadAsStream(); | ||
| using HttpResponseMessage response = http.SendAsync(request).GetAwaiter().GetResult(); | ||
| using Stream stream = response.EnsureSuccessStatusCode().Content.ReadAsStreamAsync().GetAwaiter().GetResult(); | ||
|
Comment on lines
+186
to
+187
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make async. using HttpResponseMessage response = await http.SendAsync(request);
using Stream stream = await response.EnsureSuccessStatusCode().Content.ReadAsStreamAsync();
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we should change it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of changing everywhere. You add sync in the P2P protocol function. But doesn't really matter, just looks better.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that then we need to set the method as async, and when we call it, do the same. I think that we have async code that it should be sync, like the smart contract execution |
||
| XmlDocument resp = new() { XmlResolver = null }; | ||
| resp.Load(stream); | ||
| return resp; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a copy from
neo/src/Neo.VM/Utility.cs
Line 65 in cfffe4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its wrong. Doesn't calculate right, like really big numbers or leading zeros. That's for calculating
Int32.This is how you do it,