public void Log<T>(ISmartContractState smartContractState, T toLog) where T : struct { var rawLog = new RawLog(smartContractState.Message.ContractAddress.ToUint160(), toLog); Log log = rawLog.ToLog(this.serializer); this.gasMeter.Spend(GasPriceList.LogOperationCost(log.Topics, log.Data)); // TODO: This is inefficient, it is deserializing the log more than once. this.logger.Log<T>(smartContractState, toLog); }
public void SmartContracts_GasPrice_TestLogPrices() { List <byte[]> topics = new List <byte[]> { new byte[] { 1, 2, 3, 4, 5, 6 } }; byte[] data = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var cost = (Gas)(GasPriceList.LogPerTopicByteCost * topics[0].Length + GasPriceList.LogPerByteCost * data.Length); Assert.Equal(cost, GasPriceList.LogOperationCost(topics, data)); }