Search in sources :

Example 1 with NImmutableEnvironment

use of com.icodici.universa.contract.services.NImmutableEnvironment in project universa by UniversaBlockchain.

the class EnvCache method remove.

public void remove(HashId id) {
    ;
    NImmutableEnvironment env = environemtsByContract.remove(id);
    if (env != null) {
        long envId = env.getId();
        environemtsById.remove(envId);
        environmetsExpiration.remove(envId);
    }
}
Also used : NImmutableEnvironment(com.icodici.universa.contract.services.NImmutableEnvironment)

Example 2 with NImmutableEnvironment

use of com.icodici.universa.contract.services.NImmutableEnvironment in project universa by UniversaBlockchain.

the class Node method getFullEnvironment.

/**
 * Get environment and follower contract by environment identifier.
 *
 * @param environmentId is environment subscription
 *
 * @return {@link Binder} with environment and follower contract
 */
public Binder getFullEnvironment(long environmentId) {
    NImmutableEnvironment ime = getEnvironment(environmentId);
    ime.setNameCache(nameCache);
    NSmartContract contract = ime.getContract();
    contract.setNodeInfoProvider(nodeInfoProvider);
    NMutableEnvironment me = ime.getMutable();
    if (me == null)
        return Binder.EMPTY;
    return Binder.of("follower", contract, "environment", me);
}
Also used : NSmartContract(com.icodici.universa.contract.services.NSmartContract) NMutableEnvironment(com.icodici.universa.contract.services.NMutableEnvironment) NImmutableEnvironment(com.icodici.universa.contract.services.NImmutableEnvironment)

Example 3 with NImmutableEnvironment

use of com.icodici.universa.contract.services.NImmutableEnvironment in project universa by UniversaBlockchain.

the class Node method getEnvironment.

private NImmutableEnvironment getEnvironment(NSmartContract item) {
    NImmutableEnvironment result = envCache.get(item.getId());
    if (result == null && item.getParent() != null) {
        result = envCache.get(item.getParent());
    }
    if (result == null) {
        result = ledger.getEnvironment(item);
        envCache.put(result);
    }
    return result;
}
Also used : NImmutableEnvironment(com.icodici.universa.contract.services.NImmutableEnvironment)

Example 4 with NImmutableEnvironment

use of com.icodici.universa.contract.services.NImmutableEnvironment in project universa by UniversaBlockchain.

the class TestLocalNetwork method getEnvironment.

@Override
public NImmutableEnvironment getEnvironment(HashId itemId, NodeInfo nodeInfo, Duration maxTimeout) throws InterruptedException {
    Node node = nodes.get(nodeInfo);
    NImmutableEnvironment env = node.getEnvCache().get(itemId);
    if (env != null)
        return Boss.load(Boss.pack(env));
    return null;
}
Also used : NImmutableEnvironment(com.icodici.universa.contract.services.NImmutableEnvironment)

Aggregations

NImmutableEnvironment (com.icodici.universa.contract.services.NImmutableEnvironment)4 NMutableEnvironment (com.icodici.universa.contract.services.NMutableEnvironment)1 NSmartContract (com.icodici.universa.contract.services.NSmartContract)1