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

OracleService #326

Merged
merged 176 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
05f9e74
init
Tommo-L Aug 18, 2020
78944c6
move
Tommo-L Aug 21, 2020
c033672
Merge branch 'master' into async-oracle
shargon Aug 26, 2020
6760302
Clean code
shargon Aug 26, 2020
76bee8c
Update src/Oracle/Oracle.cs
shargon Aug 26, 2020
68a2f4d
fix
Tommo-L Sep 1, 2020
9101194
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Sep 1, 2020
1cd3843
Update src/Oracle/Oracle.cs
shargon Sep 1, 2020
c31654a
fix oracle
Tommo-L Sep 8, 2020
a7b3d5f
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Sep 8, 2020
2d53f13
format
Tommo-L Sep 8, 2020
22edae9
fix
Tommo-L Sep 8, 2020
79630a6
Merge branch 'master' into async-oracle
Tommo-L Sep 8, 2020
2e64c1e
optimize
Tommo-L Sep 8, 2020
de131c4
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Sep 8, 2020
19053d2
optimize
Tommo-L Sep 9, 2020
49abda8
fix
Tommo-L Sep 15, 2020
66a5497
format
Tommo-L Sep 15, 2020
379e732
fix
Tommo-L Sep 16, 2020
a2b3f5f
add CheckOracleAccount
Tommo-L Sep 16, 2020
ffba962
fix
Tommo-L Sep 16, 2020
7aaf41b
resolve
Tommo-L Sep 17, 2020
1af31e5
Update src/Oracle/Protocol/OracleHttpProtocol.cs
shargon Sep 17, 2020
d8ec4c8
Update src/Oracle/Oracle.cs
shargon Sep 17, 2020
cc230bd
fix
Tommo-L Sep 18, 2020
0aec6db
format
Tommo-L Sep 18, 2020
60b7744
fix
Tommo-L Sep 18, 2020
ff2c4ca
Update Oracle.cs
shargon Sep 18, 2020
f51d9c0
fix timeout
Tommo-L Sep 18, 2020
3d9efc7
fix timeout2
Tommo-L Sep 18, 2020
d91f5ae
optimze
Tommo-L Sep 21, 2020
0d78083
format
Tommo-L Sep 21, 2020
6e41bc4
Apply OracleHttpProtocol.cs
Tommo-L Sep 21, 2020
91f693c
optimize
Tommo-L Sep 21, 2020
6d9e5ab
fix
Tommo-L Sep 23, 2020
4439d8c
remove
Tommo-L Sep 23, 2020
bf70455
fix
Tommo-L Sep 23, 2020
2463e84
optimize
Tommo-L Sep 24, 2020
b97ff6c
Merge branch 'master' into async-oracle
Tommo-L Sep 27, 2020
270a2c7
Apply recommmendations
Tommo-L Sep 27, 2020
41d7532
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Sep 27, 2020
11f4d51
fix
Tommo-L Sep 27, 2020
359ca79
Merge branch 'master' into async-oracle
superboyiii Oct 15, 2020
db4f0ce
Merge branch 'master' into async-oracle
superboyiii Oct 19, 2020
b190152
Merge remote-tracking branch 'upstream/master' into async-oracle
Tommo-L Oct 20, 2020
237ef4b
Merge branch 'master' into async-oracle
superboyiii Oct 21, 2020
6758e36
add backupTx
Tommo-L Oct 23, 2020
1446f3f
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Oct 23, 2020
129bd1d
sort public key
Tommo-L Oct 23, 2020
2b50e71
avoid two txs
Tommo-L Oct 23, 2020
035b894
send backup sign after timeout
Tommo-L Oct 23, 2020
db2d56a
exchange arguments of AddResponseTxSign
Tommo-L Oct 23, 2020
9406e88
format
Tommo-L Oct 23, 2020
560d7a1
format
Tommo-L Oct 23, 2020
7b04c4c
add cache
Tommo-L Oct 26, 2020
e8185ac
fix
Tommo-L Oct 28, 2020
fdc173e
optimize password
Tommo-L Oct 29, 2020
7d8ca71
up error code
Tommo-L Oct 30, 2020
6f39602
format
Tommo-L Oct 30, 2020
e25af79
Merge branch 'master' into async-oracle
superboyiii Nov 2, 2020
756161a
fix and add lock
Tommo-L Nov 4, 2020
a221d1c
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Nov 4, 2020
bc427a3
fix
Tommo-L Nov 4, 2020
5321fd8
optimize
Tommo-L Nov 4, 2020
4e4c3fc
Merge branch 'master' into async-oracle
superboyiii Nov 9, 2020
ba7f5ca
up oracle response code
Tommo-L Nov 9, 2020
93e4f98
Merge branch 'master' into async-oracle
superboyiii Nov 11, 2020
685e1e0
use base64
Tommo-L Nov 12, 2020
81e892c
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Nov 12, 2020
55dc212
Merge branch 'master' into async-oracle
shargon Nov 12, 2020
b842450
fix
Tommo-L Nov 12, 2020
9927512
Merge branch 'master' into async-oracle
shargon Nov 13, 2020
a67ffac
remove useless library
Tommo-L Nov 16, 2020
5c76239
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Nov 16, 2020
df3b851
Merge branch 'master' into async-oracle
superboyiii Nov 16, 2020
d49eb3a
fix
Tommo-L Nov 17, 2020
fcd680d
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Nov 17, 2020
d4cf93a
optimize
Tommo-L Nov 18, 2020
4c3ca6a
optimize
Tommo-L Nov 18, 2020
9e1e424
Merge branch 'master' into async-oracle
erikzhang Nov 19, 2020
77dc6a7
rename to OracleService
Tommo-L Nov 20, 2020
62e1e14
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Nov 20, 2020
868f195
Merge branch 'master' into async-oracle
shargon Nov 23, 2020
14d9423
avoid duplicate request
Tommo-L Nov 25, 2020
4a24565
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Nov 25, 2020
4750aee
fix conflicts
Tommo-L Nov 25, 2020
023784b
Replace HashsetCache by ConcurrentDictionary
Tommo-L Nov 30, 2020
b16904b
fix
Tommo-L Nov 30, 2020
0e15809
fix conflicts
Tommo-L Nov 30, 2020
27077d5
fix conflicts
Tommo-L Dec 14, 2020
f6da41e
fix
Tommo-L Dec 14, 2020
98c931a
fix
Tommo-L Dec 14, 2020
bc3d7b7
Merge branch 'master' into async-oracle
Tommo-L Dec 15, 2020
b5d0999
clean code
Tommo-L Dec 15, 2020
3f74781
rename Designate to Designation
Tommo-L Dec 15, 2020
befb3a3
Update src/Oracle/OracleService.cs
Tommo-L Dec 17, 2020
395a312
fix
Tommo-L Dec 17, 2020
36f44c9
Update projects
erikzhang Dec 17, 2020
047482e
Rename
erikzhang Dec 17, 2020
66df414
optimize code
Tommo-L Dec 17, 2020
fff4f88
static AllowPrivateHost/Timeout
Tommo-L Dec 17, 2020
9929856
Update src/OracleService/Protocols/OracleHttpProtocol.cs
Tommo-L Dec 17, 2020
3c1d6ad
apply erik's suggestion
Tommo-L Dec 17, 2020
a19940c
fix
Tommo-L Dec 17, 2020
55c770d
fix
Tommo-L Dec 17, 2020
84634ab
fix 2/2
Tommo-L Dec 17, 2020
f18a4da
Merge branch 'master' into async-oracle
Tommo-L Dec 18, 2020
348b184
Update OracleService.cs
erikzhang Dec 18, 2020
9a01b54
CI01118
erikzhang Dec 18, 2020
2c630c0
Merge branch 'master' into async-oracle
erikzhang Dec 18, 2020
b6e6bd4
add Process
Tommo-L Dec 18, 2020
074620e
Optimize
erikzhang Dec 18, 2020
01fbc3f
Remove unused parameter
erikzhang Dec 18, 2020
f7dda23
readonly
erikzhang Dec 18, 2020
ff63668
Use System.Threading.Timer
erikzhang Dec 18, 2020
8a8cb80
Rename
erikzhang Dec 18, 2020
fb0dbed
Update OracleService.cs
erikzhang Dec 18, 2020
fb1cff7
Update OracleService.cs
erikzhang Dec 18, 2020
5d85f8e
Rename
erikzhang Dec 18, 2020
92a7fa0
Add Settings.cs
erikzhang Dec 18, 2020
919df58
Move IsInternal to Helper.cs
erikzhang Dec 18, 2020
42105bf
Update OracleService.cs
erikzhang Dec 18, 2020
dd2798d
Remove Utility alias
erikzhang Dec 18, 2020
f88a750
Use a single HttpClient
erikzhang Dec 18, 2020
7b5817f
Use HttpCompletionOption.ResponseContentRead
erikzhang Dec 18, 2020
478ce59
private class
erikzhang Dec 18, 2020
a9a8c49
Simplify OracleService.cs
erikzhang Dec 18, 2020
f33c969
Use Interlocked
erikzhang Dec 18, 2020
9b5cd31
fix
Tommo-L Dec 19, 2020
05524e4
Using lock in OnTimer method
Tommo-L Dec 19, 2020
4422506
Replace lock by concurrentdictionary
Tommo-L Dec 22, 2020
cd058c5
Merge branch 'master' into async-oracle
erikzhang Dec 22, 2020
6bc6b46
Optimize
erikzhang Dec 22, 2020
253bc72
Simplify
erikzhang Dec 22, 2020
30aa901
async
erikzhang Dec 22, 2020
7883937
Prevent reentry
erikzhang Dec 22, 2020
ce78551
Optimize
erikzhang Dec 22, 2020
6572a85
private
erikzhang Dec 22, 2020
2c82d96
Prevent multiple starts
erikzhang Dec 22, 2020
a6bf504
fix
erikzhang Dec 22, 2020
f63a81a
fix
erikzhang Dec 22, 2020
dfbd954
Optimize CheckOracleAccount
erikzhang Dec 22, 2020
878b3ba
Fix OnStop
erikzhang Dec 22, 2020
1eba58d
Reorder methods
erikzhang Dec 22, 2020
3d8a9da
Optimize CreateResponseTx
erikzhang Dec 22, 2020
f7e1505
fix
Tommo-L Dec 25, 2020
470254f
Remove WithTimeout
erikzhang Dec 27, 2020
a552748
Merge branch 'master' into async-oracle
shargon Dec 28, 2020
294e620
Add check
erikzhang Dec 28, 2020
eaed2ee
add oracle ut
Tommo-L Dec 30, 2020
fab735c
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Dec 30, 2020
16185cc
Delete Neo.Plugins.OracleService.Tests.csproj
Tommo-L Dec 30, 2020
cd98a45
Delete OracleServiceTest.cs
Tommo-L Dec 30, 2020
4330353
Merge branch 'master' into async-oracle
shargon Dec 30, 2020
ca1368c
add try-catch when call Filter
Tommo-L Dec 30, 2020
ed20cac
Merge branch 'async-oracle' of https://github.com/Tommo-L/neo-modules…
Tommo-L Dec 30, 2020
4ba236d
fix and add UT
Tommo-L Jan 4, 2021
ea272c7
Remove empty line
erikzhang Jan 4, 2021
b173638
Merge branch 'master' into async-oracle
superboyiii Jan 5, 2021
973ca66
Merge branch 'master' into async-oracle
erikzhang Jan 10, 2021
f13d895
Merge branch 'master' into async-oracle
shargon Jan 11, 2021
b9ffecc
Fix OnPersist
shargon Jan 11, 2021
df70225
Optimize iteration
shargon Jan 11, 2021
10e7c2b
more optimize
erikzhang Jan 11, 2021
89a16ba
fix ut
Tommo-L Jan 12, 2021
883f779
fix
Tommo-L Jan 14, 2021
6803733
Merge branch 'master' into async-oracle
erikzhang Jan 14, 2021
e88be60
fix conflicts
Tommo-L Jan 14, 2021
3139d80
Optimize
erikzhang Jan 14, 2021
12ef99c
use random
Tommo-L Jan 14, 2021
e51a1a3
Json un-indented
shargon Jan 14, 2021
31c0d98
Replace nonce for deterministic value
shargon Jan 14, 2021
f1d5e67
Replace nonce
shargon Jan 14, 2021
15e4c49
Add UT for filters
shargon Jan 14, 2021
c4ec4fe
Merge branch 'master' into async-oracle
Tommo-L Jan 15, 2021
0acf93b
Merge branch 'master' into async-oracle
Tommo-L Jan 15, 2021
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
2 changes: 1 addition & 1 deletion src/OracleService/OracleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ private void AddResponseTxSign(StoreView snapshot, ulong requestId, ECPoint orac
}
}

private static byte[] Filter(string input, string filterArgs)
public static byte[] Filter(string input, string filterArgs)
{
if (string.IsNullOrEmpty(filterArgs))
return Utility.StrictUTF8.GetBytes(input);
Expand Down
40 changes: 40 additions & 0 deletions tests/Neo.Plugins.OracleService.Tests/UT_OracleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,46 @@ public void TestSetup()
TestBlockchain.InitializeMockNeoSystem();
}

[TestMethod]
public void TestFilter()
{
var json = @"{
'Stores': [
'Lambton Quay',
'Willis Street'
],
'Manufacturers': [
{
'Name': 'Acme Co',
'Products': [
{
'Name': 'Anvil',
'Price': 50
}
]
},
{
'Name': 'Contoso',
'Products': [
{
'Name': 'Elbow Grease',
'Price': 99.95
},
{
'Name': 'Headlight Fluid',
'Price': 4
}
]
}
]
}";

Assert.AreEqual(@"[""Acme Co""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[0].Name")));
Assert.AreEqual("[50]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[0].Products[0].Price")));
Assert.AreEqual(@"[""Elbow Grease""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[1].Products[0].Name")));
Assert.AreEqual(@"[{""Name"":""Elbow Grease"",""Price"":99.95}]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[1].Products[0]")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add Filter(json,"") and Filter(json,null)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (string.IsNullOrEmpty(filterArgs))
return Utility.StrictUTF8.GetBytes(input);

It returns the unmodified input.

}

[TestMethod]
public void TestCreateOracleResponseTx()
{
Expand Down