@Override
public NImmutableEnvironment getEnvironment(long environmentId) {
return protect(() -> {
List<byte[]> smkv = getSmartContractForEnvironmentId(environmentId);
HashId nContractHashId = HashId.withDigest(smkv.get(2));
Contract contract = NSmartContract.fromPackedTransaction(smkv.get(0));
Contract findNContract = contract.getTransactionPack().getSubItem(nContractHashId);
contract = findNContract == null ? contract : findNContract;
NSmartContract nSmartContract = (NSmartContract) contract;
Binder kvBinder = Boss.unpack(smkv.get(1));
Collection<ContractSubscription> contractSubscriptions = getContractSubscriptions(environmentId);
Collection<ContractStorage> contractStorages = getContractStorages(environmentId);
FollowerService followerService = getFollowerService(environmentId);
List<String> reducedNames = getReducedNames(environmentId);
List<NameRecord> nameRecords = new ArrayList<>();
for (String reducedName : reducedNames) {
NNameRecord nr = getNameRecord(reducedName);
nameRecords.add(nr);
}
NImmutableEnvironment nImmutableEnvironment = new NImmutableEnvironment(nSmartContract, kvBinder,
contractSubscriptions, contractStorages, nameRecords, followerService, this);
nImmutableEnvironment.setId(environmentId);
return nImmutableEnvironment;
});
}