Exemplo n.º 1
0
        private AddressEntity GetOrCreateAddress(UInt160 address)
        {
            if (address == null)
            {
                return(null);
            }
            if (_addressCache.ContainsKey(address))
            {
                return(_addressCache[address]);
            }
            var addr = address.ToBigEndianHex();
            var old  = _sqldb.Addresses.FirstOrDefault(a => a.Address == addr);

            if (old == null)
            {
                old = new AddressEntity()
                {
                    Hash = address.ToArray(), Address = addr
                };
                _sqldb.Addresses.Add(old);
                _sqldb.SaveChanges();
            }
            _addressCache[address] = old;
            return(old);
        }
Exemplo n.º 2
0
 private ContractEntity GetActiveContract(UInt160 contract)
 {
     var contractHash = contract.ToBigEndianHex();
     return _sqldb.Contracts.FirstOrDefault(c => c.Hash == contractHash && c.DeleteOrMigrateTxId == null);
 }