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

Add nep11 tracker #651

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
94c9304
init
Ashuaidehao Sep 14, 2021
c7e97ff
nep11
Ashuaidehao Sep 22, 2021
18c0443
Merge https://github.com/neo-project/neo-modules into add-nep11
Ashuaidehao Oct 9, 2021
0fd052a
mainnet
Ashuaidehao Oct 12, 2021
588d7bd
fix
Ashuaidehao Oct 13, 2021
d5440c0
is divisible
Ashuaidehao Oct 14, 2021
85e1506
Merge branch 'master' into add-nep11
superboyiii Oct 18, 2021
5f6e2d8
rename and sort
Ashuaidehao Oct 18, 2021
2715cef
group balance
Ashuaidehao Oct 18, 2021
db0861b
rename
Ashuaidehao Oct 18, 2021
2ebd447
Merge branch 'master' into add-nep11
superboyiii Oct 19, 2021
b57db78
copyright
Ashuaidehao Oct 19, 2021
66b5657
Merge branch 'add-nep11' of https://github.com/Ashuaidehao/neo-module…
Ashuaidehao Oct 19, 2021
501fce9
format
Ashuaidehao Oct 19, 2021
db6fa0d
Clean file
shargon Oct 19, 2021
f5394dc
update limit
Ashuaidehao Oct 20, 2021
f5c63ea
Merge branch 'add-nep11' of https://github.com/Ashuaidehao/neo-module…
Ashuaidehao Oct 20, 2021
9fe7098
fix network
Ashuaidehao Oct 20, 2021
51dad29
remove leveldb
Ashuaidehao Oct 21, 2021
025392c
Merge branch 'master' into add-nep11
superboyiii Oct 22, 2021
7cc8de4
Merge branch 'master' into add-nep11
superboyiii Oct 25, 2021
d28912c
format
Ashuaidehao Oct 25, 2021
2a3e1a5
Merge branch 'add-nep11' of https://github.com/Ashuaidehao/neo-module…
Ashuaidehao Oct 25, 2021
8c527f5
check SupportedStandards
Ashuaidehao Oct 27, 2021
014b4f9
Merge branch 'master' into add-nep11
superboyiii Oct 27, 2021
e9285fa
check nep11
Ashuaidehao Oct 27, 2021
72697d2
Merge branch 'add-nep11' of https://github.com/Ashuaidehao/neo-module…
Ashuaidehao Oct 27, 2021
219df5a
ignore case
Ashuaidehao Oct 28, 2021
f2cdfcd
Merge branch 'master' into add-nep11
shargon Oct 28, 2021
7556a43
update
Ashuaidehao Oct 28, 2021
e74622b
Clean files
shargon Nov 3, 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
7 changes: 7 additions & 0 deletions neo-modules.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DBFTPlugin", "src\DBFTPlugi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Plugins.RpcServer.Tests", "tests\Neo.Plugins.RpcServer.Tests\Neo.Plugins.RpcServer.Tests.csproj", "{0DDAF738-0FD3-40A7-A433-C514BCDDF542}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RpcNep11Tracker", "src\RpcNep11Tracker\RpcNep11Tracker.csproj", "{16E35B32-34CC-4525-88D5-926B7D1E7092}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -102,6 +104,10 @@ Global
{0DDAF738-0FD3-40A7-A433-C514BCDDF542}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DDAF738-0FD3-40A7-A433-C514BCDDF542}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DDAF738-0FD3-40A7-A433-C514BCDDF542}.Release|Any CPU.Build.0 = Release|Any CPU
{16E35B32-34CC-4525-88D5-926B7D1E7092}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16E35B32-34CC-4525-88D5-926B7D1E7092}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16E35B32-34CC-4525-88D5-926B7D1E7092}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16E35B32-34CC-4525-88D5-926B7D1E7092}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -122,6 +128,7 @@ Global
{149822EC-4E0C-425F-A032-4196B615BFEB} = {59D802AB-C552-422A-B9C3-64D329FBCDCC}
{90185D3E-4813-4BC1-98FE-26FD34311403} = {97E81C78-1637-481F-9485-DA1225E94C23}
{0DDAF738-0FD3-40A7-A433-C514BCDDF542} = {59D802AB-C552-422A-B9C3-64D329FBCDCC}
{16E35B32-34CC-4525-88D5-926B7D1E7092} = {97E81C78-1637-481F-9485-DA1225E94C23}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61D3ADE6-BBFC-402D-AB42-1C71C9F9EDE3}
Expand Down
63 changes: 63 additions & 0 deletions src/RpcNep11Tracker/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The neo is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using Neo.VM.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Neo.Persistence;

namespace Neo.Plugins
{
public static class Extensions
{
public static bool NotNull(this StackItem item)
{
return !item.IsNull;
}

public static string ToBase64(this ReadOnlySpan<byte> item)
{
return item == null ? String.Empty : Convert.ToBase64String(item);
}

public static int GetVarSize(this ByteString item)
{
var length = item.GetSpan().Length;
return IO.Helper.GetVarSize(length) + length;
}

public static IEnumerable<(TKey, TValue)> FindPrefix<TKey, TValue>(this IStore db, byte[] prefix)
where TKey : IEquatable<TKey>, ISerializable, new()
where TValue : class, ISerializable, new()
{
foreach (var (key, value) in db.Seek(prefix, SeekDirection.Forward))
{
if (!key.AsSpan().StartsWith(prefix)) break;
yield return (key.AsSerializable<TKey>(1), value.AsSerializable<TValue>());
}


}

public static IEnumerable<(TKey, TValue)> FindRange<TKey, TValue>(this IStore db, byte[] startKey, byte[] endKey)
where TKey : IEquatable<TKey>, ISerializable, new()
where TValue : class, ISerializable, new()
{
foreach (var (key, value) in db.Seek(startKey, SeekDirection.Forward))
{
if (key.AsSpan().SequenceCompareTo(endKey) > 0) break;
yield return (key.AsSerializable<TKey>(1), value.AsSerializable<TValue>());
}
}
}
}
Loading