diff --git a/src/neo/IO/Data/LevelDB/DB.cs b/src/neo/IO/Data/LevelDB/DB.cs
deleted file mode 100644
index 04e8f50e8f..0000000000
--- a/src/neo/IO/Data/LevelDB/DB.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using System;
-
-namespace Neo.IO.Data.LevelDB
-{
- public class DB : IDisposable
- {
- private IntPtr handle;
-
- ///
- /// Return true if haven't got valid handle
- ///
- public bool IsDisposed => handle == IntPtr.Zero;
-
- private DB(IntPtr handle)
- {
- this.handle = handle;
- }
-
- public void Dispose()
- {
- if (handle != IntPtr.Zero)
- {
- Native.leveldb_close(handle);
- handle = IntPtr.Zero;
- }
- }
-
- public void Delete(WriteOptions options, Slice key)
- {
- IntPtr error;
- Native.leveldb_delete(handle, options.handle, key.buffer, (UIntPtr)key.buffer.Length, out error);
- NativeHelper.CheckError(error);
- }
-
- public Slice Get(ReadOptions options, Slice key)
- {
- UIntPtr length;
- IntPtr error;
- IntPtr value = Native.leveldb_get(handle, options.handle, key.buffer, (UIntPtr)key.buffer.Length, out length, out error);
- try
- {
- NativeHelper.CheckError(error);
- if (value == IntPtr.Zero)
- throw new LevelDBException("not found");
- return new Slice(value, length);
- }
- finally
- {
- if (value != IntPtr.Zero) Native.leveldb_free(value);
- }
- }
-
- public Snapshot GetSnapshot()
- {
- return new Snapshot(handle);
- }
-
- public Iterator NewIterator(ReadOptions options)
- {
- return new Iterator(Native.leveldb_create_iterator(handle, options.handle));
- }
-
- public static DB Open(string name)
- {
- return Open(name, Options.Default);
- }
-
- public static DB Open(string name, Options options)
- {
- IntPtr error;
- IntPtr handle = Native.leveldb_open(options.handle, name, out error);
- NativeHelper.CheckError(error);
- return new DB(handle);
- }
-
- public void Put(WriteOptions options, Slice key, Slice value)
- {
- IntPtr error;
- Native.leveldb_put(handle, options.handle, key.buffer, (UIntPtr)key.buffer.Length, value.buffer, (UIntPtr)value.buffer.Length, out error);
- NativeHelper.CheckError(error);
- }
-
- public bool TryGet(ReadOptions options, Slice key, out Slice value)
- {
- UIntPtr length;
- IntPtr error;
- IntPtr v = Native.leveldb_get(handle, options.handle, key.buffer, (UIntPtr)key.buffer.Length, out length, out error);
- if (error != IntPtr.Zero)
- {
- Native.leveldb_free(error);
- value = default(Slice);
- return false;
- }
- if (v == IntPtr.Zero)
- {
- value = default(Slice);
- return false;
- }
- value = new Slice(v, length);
- Native.leveldb_free(v);
- return true;
- }
-
- public void Write(WriteOptions options, WriteBatch write_batch)
- {
- // There's a bug in .Net Core.
- // When calling DB.Write(), it will throw LevelDBException sometimes.
- // But when you try to catch the exception, the bug disappears.
- // We shall remove the "try...catch" clause when Microsoft fix the bug.
- byte retry = 0;
- while (true)
- {
- try
- {
- IntPtr error;
- Native.leveldb_write(handle, options.handle, write_batch.handle, out error);
- NativeHelper.CheckError(error);
- break;
- }
- catch (LevelDBException ex)
- {
- if (++retry >= 4) throw;
- System.IO.File.AppendAllText("leveldb.log", ex.Message + "\r\n");
- }
- }
- }
- }
-}
diff --git a/src/neo/IO/Data/LevelDB/Helper.cs b/src/neo/IO/Data/LevelDB/Helper.cs
deleted file mode 100644
index 585d282414..0000000000
--- a/src/neo/IO/Data/LevelDB/Helper.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Neo.IO.Data.LevelDB
-{
- public static class Helper
- {
- public static void Delete(this WriteBatch batch, byte prefix, ISerializable key)
- {
- batch.Delete(SliceBuilder.Begin(prefix).Add(key));
- }
-
- public static IEnumerable Find(this DB db, ReadOptions options, byte prefix) where T : class, ISerializable, new()
- {
- return Find(db, options, SliceBuilder.Begin(prefix), (k, v) => v.ToArray().AsSerializable());
- }
-
- public static IEnumerable Find(this DB db, ReadOptions options, Slice prefix, Func resultSelector)
- {
- using (Iterator it = db.NewIterator(options))
- {
- for (it.Seek(prefix); it.Valid(); it.Next())
- {
- Slice key = it.Key();
- byte[] x = key.ToArray();
- byte[] y = prefix.ToArray();
- if (x.Length < y.Length) break;
- if (!x.AsSpan().StartsWith(y)) break;
- yield return resultSelector(key, it.Value());
- }
- }
- }
-
- public static T Get(this DB db, ReadOptions options, byte prefix, ISerializable key) where T : class, ISerializable, new()
- {
- return db.Get(options, SliceBuilder.Begin(prefix).Add(key)).ToArray().AsSerializable();
- }
-
- public static T Get(this DB db, ReadOptions options, byte prefix, ISerializable key, Func resultSelector)
- {
- return resultSelector(db.Get(options, SliceBuilder.Begin(prefix).Add(key)));
- }
-
- public static void Put(this WriteBatch batch, byte prefix, ISerializable key, ISerializable value)
- {
- batch.Put(SliceBuilder.Begin(prefix).Add(key), value.ToArray());
- }
-
- public static T TryGet(this DB db, ReadOptions options, byte prefix, ISerializable key) where T : class, ISerializable, new()
- {
- Slice slice;
- if (!db.TryGet(options, SliceBuilder.Begin(prefix).Add(key), out slice))
- return null;
- return slice.ToArray().AsSerializable();
- }
-
- public static T TryGet(this DB db, ReadOptions options, byte prefix, ISerializable key, Func resultSelector) where T : class
- {
- Slice slice;
- if (!db.TryGet(options, SliceBuilder.Begin(prefix).Add(key), out slice))
- return null;
- return resultSelector(slice);
- }
- }
-}
diff --git a/src/neo/IO/Data/LevelDB/Iterator.cs b/src/neo/IO/Data/LevelDB/Iterator.cs
deleted file mode 100644
index b3a6a0bfe0..0000000000
--- a/src/neo/IO/Data/LevelDB/Iterator.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-
-namespace Neo.IO.Data.LevelDB
-{
- public class Iterator : IDisposable
- {
- private IntPtr handle;
-
- internal Iterator(IntPtr handle)
- {
- this.handle = handle;
- }
-
- private void CheckError()
- {
- IntPtr error;
- Native.leveldb_iter_get_error(handle, out error);
- NativeHelper.CheckError(error);
- }
-
- public void Dispose()
- {
- if (handle != IntPtr.Zero)
- {
- Native.leveldb_iter_destroy(handle);
- handle = IntPtr.Zero;
- }
- }
-
- public Slice Key()
- {
- UIntPtr length;
- IntPtr key = Native.leveldb_iter_key(handle, out length);
- CheckError();
- return new Slice(key, length);
- }
-
- public void Next()
- {
- Native.leveldb_iter_next(handle);
- CheckError();
- }
-
- public void Prev()
- {
- Native.leveldb_iter_prev(handle);
- CheckError();
- }
-
- public void Seek(Slice target)
- {
- Native.leveldb_iter_seek(handle, target.buffer, (UIntPtr)target.buffer.Length);
- }
-
- public void SeekToFirst()
- {
- Native.leveldb_iter_seek_to_first(handle);
- }
-
- public void SeekToLast()
- {
- Native.leveldb_iter_seek_to_last(handle);
- }
-
- public bool Valid()
- {
- return Native.leveldb_iter_valid(handle);
- }
-
- public Slice Value()
- {
- UIntPtr length;
- IntPtr value = Native.leveldb_iter_value(handle, out length);
- CheckError();
- return new Slice(value, length);
- }
- }
-}
diff --git a/src/neo/IO/Data/LevelDB/LevelDBException.cs b/src/neo/IO/Data/LevelDB/LevelDBException.cs
deleted file mode 100644
index 8804f1f7f2..0000000000
--- a/src/neo/IO/Data/LevelDB/LevelDBException.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System.Data.Common;
-
-namespace Neo.IO.Data.LevelDB
-{
- public class LevelDBException : DbException
- {
- internal LevelDBException(string message)
- : base(message)
- {
- }
- }
-}
diff --git a/src/neo/IO/Data/LevelDB/Native.cs b/src/neo/IO/Data/LevelDB/Native.cs
deleted file mode 100644
index c83d3913f8..0000000000
--- a/src/neo/IO/Data/LevelDB/Native.cs
+++ /dev/null
@@ -1,249 +0,0 @@
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace Neo.IO.Data.LevelDB
-{
- public enum CompressionType : byte
- {
- kNoCompression = 0x0,
- kSnappyCompression = 0x1
- }
-
- public static class Native
- {
- #region Logger
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_logger_create(IntPtr /* Action */ logger);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_logger_destroy(IntPtr /* logger*/ option);
- #endregion
-
- #region DB
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_open(IntPtr /* Options*/ options, string name, out IntPtr error);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_close(IntPtr /*DB */ db);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_put(IntPtr /* DB */ db, IntPtr /* WriteOptions*/ options, byte[] key, UIntPtr keylen, byte[] val, UIntPtr vallen, out IntPtr errptr);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_delete(IntPtr /* DB */ db, IntPtr /* WriteOptions*/ options, byte[] key, UIntPtr keylen, out IntPtr errptr);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_write(IntPtr /* DB */ db, IntPtr /* WriteOptions*/ options, IntPtr /* WriteBatch */ batch, out IntPtr errptr);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_get(IntPtr /* DB */ db, IntPtr /* ReadOptions*/ options, byte[] key, UIntPtr keylen, out UIntPtr vallen, out IntPtr errptr);
-
- //[DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- //static extern void leveldb_approximate_sizes(IntPtr /* DB */ db, int num_ranges, byte[] range_start_key, long range_start_key_len, byte[] range_limit_key, long range_limit_key_len, out long sizes);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_create_iterator(IntPtr /* DB */ db, IntPtr /* ReadOption */ options);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_create_snapshot(IntPtr /* DB */ db);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_release_snapshot(IntPtr /* DB */ db, IntPtr /* SnapShot*/ snapshot);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_property_value(IntPtr /* DB */ db, string propname);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_repair_db(IntPtr /* Options*/ options, string name, out IntPtr error);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_destroy_db(IntPtr /* Options*/ options, string name, out IntPtr error);
-
- #region extensions
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_free(IntPtr /* void */ ptr);
-
- #endregion
-
-
- #endregion
-
- #region Env
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_create_default_env();
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_env_destroy(IntPtr /*Env*/ cache);
- #endregion
-
- #region Iterator
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_iter_destroy(IntPtr /*Iterator*/ iterator);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- [return: MarshalAs(UnmanagedType.U1)]
- public static extern bool leveldb_iter_valid(IntPtr /*Iterator*/ iterator);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_iter_seek_to_first(IntPtr /*Iterator*/ iterator);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_iter_seek_to_last(IntPtr /*Iterator*/ iterator);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_iter_seek(IntPtr /*Iterator*/ iterator, byte[] key, UIntPtr length);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_iter_next(IntPtr /*Iterator*/ iterator);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_iter_prev(IntPtr /*Iterator*/ iterator);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_iter_key(IntPtr /*Iterator*/ iterator, out UIntPtr length);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_iter_value(IntPtr /*Iterator*/ iterator, out UIntPtr length);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_iter_get_error(IntPtr /*Iterator*/ iterator, out IntPtr error);
- #endregion
-
- #region Options
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_options_create();
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_destroy(IntPtr /*Options*/ options);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_create_if_missing(IntPtr /*Options*/ options, [MarshalAs(UnmanagedType.U1)] bool o);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_error_if_exists(IntPtr /*Options*/ options, [MarshalAs(UnmanagedType.U1)] bool o);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_info_log(IntPtr /*Options*/ options, IntPtr /* Logger */ logger);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_paranoid_checks(IntPtr /*Options*/ options, [MarshalAs(UnmanagedType.U1)] bool o);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_env(IntPtr /*Options*/ options, IntPtr /*Env*/ env);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_write_buffer_size(IntPtr /*Options*/ options, UIntPtr size);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_max_open_files(IntPtr /*Options*/ options, int max);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_cache(IntPtr /*Options*/ options, IntPtr /*Cache*/ cache);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_block_size(IntPtr /*Options*/ options, UIntPtr size);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_block_restart_interval(IntPtr /*Options*/ options, int interval);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_compression(IntPtr /*Options*/ options, CompressionType level);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_comparator(IntPtr /*Options*/ options, IntPtr /*Comparator*/ comparer);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_options_set_filter_policy(IntPtr /*Options*/ options, IntPtr /*FilterPolicy*/ policy);
- #endregion
-
- #region ReadOptions
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_readoptions_create();
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_readoptions_destroy(IntPtr /*ReadOptions*/ options);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_readoptions_set_verify_checksums(IntPtr /*ReadOptions*/ options, [MarshalAs(UnmanagedType.U1)] bool o);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_readoptions_set_fill_cache(IntPtr /*ReadOptions*/ options, [MarshalAs(UnmanagedType.U1)] bool o);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_readoptions_set_snapshot(IntPtr /*ReadOptions*/ options, IntPtr /*SnapShot*/ snapshot);
- #endregion
-
- #region WriteBatch
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr leveldb_writebatch_create();
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_writebatch_destroy(IntPtr /* WriteBatch */ batch);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_writebatch_clear(IntPtr /* WriteBatch */ batch);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_writebatch_put(IntPtr /* WriteBatch */ batch, byte[] key, UIntPtr keylen, byte[] val, UIntPtr vallen);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_writebatch_delete(IntPtr /* WriteBatch */ batch, byte[] key, UIntPtr keylen);
-
- [DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern void leveldb_writebatch_iterate(IntPtr /* WriteBatch */ batch, object state, Action