diff --git a/AElf.Kernel/Chain.cs b/AElf.Kernel/Chain.cs
index 2061d357b3..916fdb2ba2 100644
--- a/AElf.Kernel/Chain.cs
+++ b/AElf.Kernel/Chain.cs
@@ -10,21 +10,8 @@ public class Chain : IChain
/// The blocks.
public List Blocks { get; set; } = new List();
- public long CurrentBlockHeight
- {
- get
- {
- return Blocks.Count;
- }
- }
-
- public IHash CurrentBlockHash
- {
- get
- {
- return new Hash(Blocks[Blocks.Count - 1].GetHeader().GetTransactionMerkleTreeRoot().Value);
- }
- }
+ public long CurrentBlockHeight => Blocks.Count;
+ public IHash CurrentBlockHash => new Hash(Blocks[Blocks.Count - 1].GetHeader().GetTransactionMerkleTreeRoot().Value);
}
}
\ No newline at end of file
diff --git a/AElf.Kernel/ChainManager.cs b/AElf.Kernel/ChainManager.cs
index 6426cf7333..ae74f04ce2 100644
--- a/AElf.Kernel/ChainManager.cs
+++ b/AElf.Kernel/ChainManager.cs
@@ -16,7 +16,7 @@ public class ChainManager : IChainManager
public Task AddBlockAsync(IChain chain, IBlock block)
{
return new Task(() =>(chain as Chain).Blocks.Add(block as Block));
-
- }
+ }
+
}
}
\ No newline at end of file
diff --git a/AElf.Kernel/IAccount.cs b/AElf.Kernel/IAccount.cs
index bc2795b625..3cfbab4f29 100644
--- a/AElf.Kernel/IAccount.cs
+++ b/AElf.Kernel/IAccount.cs
@@ -12,7 +12,5 @@ public interface IAccount
///
///
IHash GetAddress();
-
- ISmartContractInvoker CreateInvoker(string methodName, params object[] values);
}
}
\ No newline at end of file
diff --git a/AElf.Kernel/IAccountDataContext.cs b/AElf.Kernel/IAccountDataContext.cs
new file mode 100644
index 0000000000..03ebc5f311
--- /dev/null
+++ b/AElf.Kernel/IAccountDataContext.cs
@@ -0,0 +1,7 @@
+namespace AElf.Kernel
+{
+ public interface IAccountDataContext
+ {
+ ulong IncreasementId { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/AElf.Kernel/IAccountDataProvider.cs b/AElf.Kernel/IAccountDataProvider.cs
index 8222119b83..ab7a792b12 100644
--- a/AElf.Kernel/IAccountDataProvider.cs
+++ b/AElf.Kernel/IAccountDataProvider.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading.Tasks;
namespace AElf.Kernel
{
@@ -7,29 +8,11 @@ namespace AElf.Kernel
///
public interface IAccountDataProvider
{
- ///
- /// Gets the data merkle tree root.
- ///
- ///
- Task>> GetDataMerkleTreeRootAsync();
-
- ///
- ///
- ///
- ///
- ///
- Task GetAsync(IHash key);
-
- ///
- ///
- ///
- ///
- ///
- ///
- Task SetAsync(IHash key,ISerializable obj);
+
+ IAccountDataContext Context { get; set; }
IHash GetAccountAddress();
- Task GetMapAsync(string name);
+ IDataProvider GetDataProvider();
}
}
\ No newline at end of file
diff --git a/AElf.Kernel/IDataProvider.cs b/AElf.Kernel/IDataProvider.cs
new file mode 100644
index 0000000000..3d47287288
--- /dev/null
+++ b/AElf.Kernel/IDataProvider.cs
@@ -0,0 +1,32 @@
+using System.Threading.Tasks;
+
+namespace AElf.Kernel
+{
+ public interface IDataProvider
+ {
+ IDataProvider GetDataProvider(string name);
+
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task GetAsync(IHash key);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task SetAsync(IHash key,ISerializable obj);
+
+ ///
+ /// Gets the data merkle tree root.
+ ///
+ ///
+ Task>> GetDataMerkleTreeRootAsync();
+
+ }
+}
\ No newline at end of file
diff --git a/AElf.Kernel/ISmartContract.cs b/AElf.Kernel/ISmartContract.cs
new file mode 100644
index 0000000000..9b92cae1bf
--- /dev/null
+++ b/AElf.Kernel/ISmartContract.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace AElf.Kernel
+{
+
+ public interface ISmartContract
+ {
+ Task InititalizeAsync(IAccountDataProvider dataProvider);
+ Task InvokeAsync(IHash caller,
+ string methodname, params object[] objs);
+ }
+
+}
\ No newline at end of file
diff --git a/AElf.Kernel/ISmartContractInvoker.cs b/AElf.Kernel/ISmartContractInvoker.cs
deleted file mode 100644
index f365e93e77..0000000000
--- a/AElf.Kernel/ISmartContractInvoker.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System.Threading.Tasks;
-
-namespace AElf.Kernel
-{
- public interface ISmartContractInvoker
- {
- Task InvokeAsync(IAccountDataProvider accountDataProvider);
- }
-}
\ No newline at end of file
diff --git a/AElf.Kernel/ISmartContractManager.cs b/AElf.Kernel/ISmartContractManager.cs
new file mode 100644
index 0000000000..1f61a2dd2e
--- /dev/null
+++ b/AElf.Kernel/ISmartContractManager.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace AElf.Kernel
+{
+ public interface ISmartContractManager
+ {
+ Task GetAsync(IAccount account);
+ }
+}
\ No newline at end of file
diff --git a/AElf.Kernel/ITransaction.cs b/AElf.Kernel/ITransaction.cs
index c642b1a4d0..5f397e7290 100644
--- a/AElf.Kernel/ITransaction.cs
+++ b/AElf.Kernel/ITransaction.cs
@@ -42,4 +42,5 @@ public interface ITransaction
ulong IncrementId { get; set; }
}
+
}
\ No newline at end of file
diff --git a/AElf.Kernel/KernelAccount/AccountZero.cs b/AElf.Kernel/KernelAccount/AccountZero.cs
index 6dc648756b..d6092dbefc 100644
--- a/AElf.Kernel/KernelAccount/AccountZero.cs
+++ b/AElf.Kernel/KernelAccount/AccountZero.cs
@@ -15,10 +15,5 @@ public IHash GetAddress()
{
return Hash.Zero;
}
-
- public ISmartContractInvoker CreateInvoker(string methodName, params object[] values)
- {
- throw new NotImplementedException();
- }
}
}
\ No newline at end of file
diff --git a/AElf.Kernel/KernelAccount/SmartContractInvokerZero.cs b/AElf.Kernel/KernelAccount/SmartContractInvokerZero.cs
deleted file mode 100644
index 1593b1b1cb..0000000000
--- a/AElf.Kernel/KernelAccount/SmartContractInvokerZero.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Threading.Tasks;
-
-namespace AElf.Kernel.KernelAccount
-{
- public class SmartContractInvokerZero : ISmartContractInvoker
- {
- private SmartContractZero _contract;
- private readonly string _methodName;
- private readonly object[] _objs;
-
- private static Type _type = typeof(SmartContractZero);
-
- public SmartContractInvokerZero(
- SmartContractZero contract,string methodName,params object[] objs)
- {
- _contract = contract;
- _methodName = methodName;
- _objs = objs;
- }
-
- public async Task InvokeAsync(IAccountDataProvider accountDataProvider)
- {
- //First step, setup data access driver
- }
- }
-}
\ No newline at end of file
diff --git a/AElf.Kernel/KernelAccount/SmartContractZero.cs b/AElf.Kernel/KernelAccount/SmartContractZero.cs
index 644b0b1e9a..5aa9cf99b7 100644
--- a/AElf.Kernel/KernelAccount/SmartContractZero.cs
+++ b/AElf.Kernel/KernelAccount/SmartContractZero.cs
@@ -1,16 +1,18 @@
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading.Tasks;
namespace AElf.Kernel.KernelAccount
{
- public class SmartContractZero
+ public class SmartContractZero: ISmartContract
{
private const string SMART_CONTRACT_MAP_KEY = "SmartContractMap";
private IAccountDataProvider _accountDataProvider;
- public async void InititalizeAsync(IAccountDataProvider dataProvider)
+ public async Task InititalizeAsync(IAccountDataProvider dataProvider)
{
_accountDataProvider = dataProvider;
+ await Task.CompletedTask;
}
public async Task InvokeAsync(IHash caller, string methodname, params object[] objs)
@@ -24,7 +26,7 @@ public async Task InvokeAsync(IHash caller, string methodname, params
// Hard coded method in the kernel
public async Task RegisterSmartContract(SmartContractRegistration reg)
{
- var smartContractMap = (IAccountDataProvider) await _accountDataProvider.GetMapAsync(SMART_CONTRACT_MAP_KEY);
+ var smartContractMap = _accountDataProvider.GetDataProvider().GetDataProvider(SMART_CONTRACT_MAP_KEY);
await smartContractMap.SetAsync(reg.Hash, reg);
}
}
diff --git a/AElf.Kernel/SmartContractRegistration.cs b/AElf.Kernel/SmartContractRegistration.cs
index 2f36805c90..993dd0ead6 100644
--- a/AElf.Kernel/SmartContractRegistration.cs
+++ b/AElf.Kernel/SmartContractRegistration.cs
@@ -1,21 +1,18 @@
namespace AElf.Kernel
{
-
-
public class SmartContractRegistration : ISerializable
{
-
///
/// 0: Smart Contract Zero
/// 1: C# bytes
/// 2: Javascript
///
public int Category { get; set; }
-
+
public IHash Hash { get; set; }
-
+
public byte[] Bytes { get; set; }
-
+
public byte[] Serialize()
{
throw new System.NotImplementedException();
diff --git a/AElf.Kernel/TransactionExecutingManager.cs b/AElf.Kernel/TransactionExecutingManager.cs
index 055f4a5288..b8ee1b5e2d 100644
--- a/AElf.Kernel/TransactionExecutingManager.cs
+++ b/AElf.Kernel/TransactionExecutingManager.cs
@@ -28,6 +28,7 @@ public Task ExecuteAsync(ITransaction tx)
var task = Task.Factory.StartNew(() =>
{
var a = 1 + 1;
+ a += 1;
});
return task;
}