示例#1
0
        /// <summary>
        /// save contract change info into sqldb immediately
        /// </summary>
        /// <param name="contractEvent"></param>
        /// <param name="txId"></param>
        /// <param name="blockTime"></param>
        private void ProcessContractEvent(ContractEventInfo contractEvent, UInt256 txId, DateTime blockTime)
        {
            switch (contractEvent.Event)
            {
            case ContractEventType.Create:
            {
                var newContract = GenerateNewNep5ContractInfo(contractEvent.Contract, txId, blockTime);
                newContract.Name = contractEvent.Name;
                _db.CreateContract(newContract);
                break;
            }

            case ContractEventType.Destroy:
                _db.DeleteContract(contractEvent.Contract, txId, blockTime);
                break;

            case ContractEventType.Migrate:
                var migrateContract = GenerateNewNep5ContractInfo(contractEvent.MigrateToContract, txId, blockTime);
                _db.MigrateContract(contractEvent.Contract, migrateContract, txId, blockTime);
                break;
            }
        }