protected override async Task ProcessLogEventAsync(Block block, LogEvent logEvent)
        {
            var eventData = new ContractDeployed();

            eventData.MergeFrom(logEvent);

            var chainContext = new ChainContext
            {
                BlockHash   = block.GetHash(),
                BlockHeight = block.Height
            };

            var smartContractRegistration =
                await _smartContractRegistrationInStateProvider.GetSmartContractRegistrationAsync(chainContext
                                                                                                  , eventData.Address);

            await _smartContractRegistrationProvider.SetSmartContractRegistrationAsync(chainContext, eventData.Address,
                                                                                       smartContractRegistration);

            if (block.Height > AElfConstants.GenesisBlockHeight)
            {
                _smartContractExecutiveService.CleanExecutive(eventData.Address);
            }

            if (eventData.Name != null)
            {
                await _smartContractAddressService.SetSmartContractAddressAsync(chainContext, eventData.Name.ToStorageKey(),
                                                                                eventData.Address);
            }

            Logger.LogDebug($"Deployed contract {eventData}");
        }
Esempio n. 2
0
        public async Task ProcessAsync(Block block, TransactionResult transactionResult, LogEvent logEvent)
        {
            var eventData = new ContractDeployed();

            eventData.MergeFrom(logEvent);

            var smartContractRegistration =
                await _smartContractRegistrationInStateProvider.GetSmartContractRegistrationAsync(new ChainContext
            {
                BlockHash   = block.GetHash(),
                BlockHeight = block.Height
            }, eventData.Address);

            await _smartContractRegistrationProvider.SetSmartContractRegistrationAsync(new BlockIndex
            {
                BlockHash   = block.GetHash(),
                BlockHeight = block.Height
            }, eventData.Address, smartContractRegistration);

            if (block.Height > AElfConstants.GenesisBlockHeight)
            {
                _smartContractExecutiveService.CleanExecutive(eventData.Address);
            }
            Logger.LogDebug($"Deployed contract {eventData}");
        }
Esempio n. 3
0
        protected override async Task ProcessLogEventAsync(Block block, LogEvent logEvent)
        {
            var eventData = new CodeUpdated();

            eventData.MergeFrom(logEvent);

            var chainContext = new ChainContext
            {
                BlockHash   = block.GetHash(),
                BlockHeight = block.Height
            };
            var smartContractRegistration =
                await _smartContractRegistrationInStateProvider.GetSmartContractRegistrationAsync(chainContext,
                                                                                                  eventData.Address);

            await _smartContractRegistrationProvider.SetSmartContractRegistrationAsync(chainContext, eventData.Address,
                                                                                       smartContractRegistration);

            _smartContractExecutiveService.CleanExecutive(eventData.Address);

            Logger.LogDebug($"Updated contract {eventData}");
        }