Skip to content

Commit

Permalink
Modified the code to reflect current design
Browse files Browse the repository at this point in the history
  • Loading branch information
samfrb committed Feb 2, 2018
1 parent 47a9840 commit 5c88f12
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 75 deletions.
18 changes: 10 additions & 8 deletions AElf.Kernel/IAccountDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ public interface IAccountDataProvider
Task<IHash<IMerkleTree<ISerializable>>> GetDataMerkleTreeRootAsync();

/// <summary>
/// Gets the async.
///
/// </summary>
/// <param name="address"></param>
/// <param name="key"></param>
/// <returns></returns>
Task<ISerializable> GetAsync(IHash address);
Task<ISerializable> GetAsync(IHash key);

/// <summary>
///
/// </summary>
/// <param name="address"></param>
/// <param name="key"></param>
/// <param name="obj"></param>
/// <returns></returns>
Task SetAsync(IHash address,ISerializable obj);

object Context { get; set; }

Task SetAsync(IHash key,ISerializable obj);

IHash<IAccount> GetAccountAddress();

Task<IAccountDataProvider> GetMapAsync(string name);
}
}
9 changes: 2 additions & 7 deletions AElf.Kernel/KernelAccount/AccountZero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

namespace AElf.Kernel.KernelAccount
{
public class AccountZero:IAccount
public class AccountZero : IAccount
{
private SmartContractZero _smartContractZero;



public AccountZero(SmartContractZero smartContractZero)
{
_smartContractZero = smartContractZero;

}



public IHash<IAccount> GetAddress()
{
return Hash<IAccount>.Zero;
Expand All @@ -24,6 +20,5 @@ public ISmartContractInvoker CreateInvoker(string methodName, params object[] va
{
throw new NotImplementedException();
}

}
}
4 changes: 1 addition & 3 deletions AElf.Kernel/KernelAccount/SmartContractInvokerZero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace AElf.Kernel.KernelAccount
{
public class SmartContractInvokerZero: ISmartContractInvoker
public class SmartContractInvokerZero : ISmartContractInvoker
{

private SmartContractZero _contract;
Expand All @@ -23,8 +23,6 @@ public SmartContractInvokerZero(
public async Task InvokeAsync(IAccountDataProvider accountDataProvider)
{
//First step, setup data access driver


}
}
}
26 changes: 25 additions & 1 deletion AElf.Kernel/KernelAccount/SmartContractZero.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
namespace AElf.Kernel.KernelAccount
using System.Threading.Tasks;

namespace AElf.Kernel.KernelAccount
{
public class SmartContractZero
{
private const string SMART_CONTRACT_MAP_KEY = "SmartContractMap";

private IAccountDataProvider _accountDataProvider;

public async void InititalizeAsync(IAccountDataProvider dataProvider)
{
_accountDataProvider = dataProvider;
}

public async Task InvokeAsync(IHash<IAccount> caller, string methodname, params object[] objs)
{
var type = typeof(SmartContractZero);
var member = type.GetMethod(methodname);

await (Task) member.Invoke(this, objs);
}

// Hard coded method in the kernel
public async Task RegisterSmartContract(SmartContractRegistration reg)
{
var smartContractMap = (IAccountDataProvider) await _accountDataProvider.GetMapAsync(SMART_CONTRACT_MAP_KEY);
await smartContractMap.SetAsync(reg.Hash, reg);
}
}
}
55 changes: 0 additions & 55 deletions AElf.Kernel/LiteDBDataProvider.cs

This file was deleted.

7 changes: 6 additions & 1 deletion AElf.Kernel/SmartContractRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{


public class SmartContractRegistration
public class SmartContractRegistration : ISerializable
{

/// <summary>
Expand All @@ -15,5 +15,10 @@ public class SmartContractRegistration
public IHash Hash { get; set; }

public byte[] Bytes { get; set; }

public byte[] Serialize()
{
throw new System.NotImplementedException();
}
}
}

0 comments on commit 5c88f12

Please sign in to comment.