internal DataAccount GetDataAccount(long accountId, bool newFromServiceChain = true) { if (_dataAccounts.TryGetValue(accountId, out var account)) { return(account); } var data = _dataAccountStorage.GetBlockData(accountId); if (data == null) { if (newFromServiceChain) { var serviceAccount = _serviceChain.GetServiceAccount(accountId); if (serviceAccount != null) { lock (_lock) { if (!_dataAccounts.TryGetValue(accountId, out var dataAccount)) { if (_serviceChain.ServiceAccountExists(accountId)) { dataAccount = new DataAccount(accountId); _dataAccounts[accountId] = dataAccount; _dataAccountStorage.AddEntry(accountId, dataAccount.ToByteArray()); //TaskRunner.Run(_dataAccountStorage.Commit); } } return(dataAccount); } } } return(null); } using (var unpacker = new Unpacker(data)) { account = new DataAccount(unpacker); lock (_lock) { if (_dataAccounts.TryGetValue(accountId, out var storedAccount)) { return(storedAccount); } if (account.AccountId != accountId) { throw new Exception("Invalid data account data"); } _dataAccounts[accountId] = account; } return(account); } }
public override bool FeatureAccountExists(long accountId) { return(ServiceChain.ServiceAccountExists(accountId)); }