aelf系统交易机制
概述
实现
public interface ISystemTransactionGenerator
{
Task<List<Transaction>> GenerateTransactionsAsync(Address from, long preBlockHeight, Hash preBlockHash);
}实现
所属模块
生成的交易
作用
备注
Last updated
public interface ISystemTransactionGenerator
{
Task<List<Transaction>> GenerateTransactionsAsync(Address from, long preBlockHeight, Hash preBlockHash);
}Last updated
public class DeployContractsSystemTransactionGenerator : ISystemTransactionGenerator
{
private readonly ITransactionGeneratingService _transactionGeneratingService;
private readonly ContractOptions _contractOptions;
public DeployContractsSystemTransactionGenerator(ITransactionGeneratingService transactionGeneratingService,
IOptionsSnapshot<ContractOptions> contractOptions)
{
_transactionGeneratingService = transactionGeneratingService;
_contractOptions = contractOptions.Value;
}
public async Task<List<Transaction>> GenerateTransactionsAsync(Address @from, long preBlockHeight,
Hash preBlockHash)
{
if (preBlockHeight == 1)
{
var code = ByteString.CopyFrom(GetContractCodes());
return new List<Transaction>
{
await _transactionGeneratingService.GenerateTransactionAsync(
ZeroSmartContractAddressNameProvider.Name, nameof(BasicContractZero.DeploySmartContract),
new ContractDeploymentInput
{
Category = KernelConstants.DefaultRunnerCategory,
Code = code
}.ToByteString())
};
}
return new List<Transaction>();
}
private byte[] GetContractCodes()
{
return ContractsDeployer.GetContractCodes<DeployContractsSystemTransactionGenerator>(_contractOptions
.GenesisContractDir)["AElf.Contracts.BingoContract"];
}
}