Search in sources :

Example 6 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class AccountsReader method from.

public static MerkleMap<EntityNum, MerkleAccount> from(String loc) throws Exception {
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleLong.class, MerkleLong::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(FCQueue.class, FCQueue::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleMap.class, MerkleMap::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleEntityId.class, MerkleEntityId::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccount.class, MerkleAccount::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccountState.class, MerkleAccountState::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(ExpirableTxnRecord.class, ExpirableTxnRecord::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(TxnReceipt.class, TxnReceipt::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(TxnId.class, TxnId::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(CurrencyAdjustments.class, CurrencyAdjustments::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(EvmFnResult.class, EvmFnResult::new));
    try (MerkleDataInputStream in = new MerkleDataInputStream(Files.newInputStream(Path.of(loc)))) {
        MerkleMap<EntityNum, MerkleAccount> fcm = in.readMerkleTree(Integer.MAX_VALUE);
        return fcm;
    }
}
Also used : ExpirableTxnRecord(com.hedera.services.state.submerkle.ExpirableTxnRecord) FCQueue(com.swirlds.fcqueue.FCQueue) MerkleDataInputStream(com.swirlds.common.merkle.io.MerkleDataInputStream) TxnReceipt(com.hedera.services.legacy.core.jproto.TxnReceipt) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) MerkleEntityId(com.hedera.services.state.merkle.MerkleEntityId) MerkleAccountState(com.hedera.services.state.merkle.MerkleAccountState) EntityNum(com.hedera.services.utils.EntityNum) MerkleLong(com.swirlds.common.merkle.utility.MerkleLong) EntityId(com.hedera.services.state.submerkle.EntityId) MerkleEntityId(com.hedera.services.state.merkle.MerkleEntityId) TxnId(com.hedera.services.state.submerkle.TxnId) EvmFnResult(com.hedera.services.state.submerkle.EvmFnResult) MerkleMap(com.swirlds.merkle.map.MerkleMap) CurrencyAdjustments(com.hedera.services.state.submerkle.CurrencyAdjustments) ClassConstructorPair(com.swirlds.common.constructable.ClassConstructorPair)

Example 7 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class FcmToJsonUtil method convertAccountsToJson.

@Test
void convertAccountsToJson() throws Exception {
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleLong.class, MerkleLong::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(FCQueue.class, FCQueue::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleEntityId.class, MerkleEntityId::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccount.class, MerkleAccount::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccountState.class, MerkleAccountState::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(ExpirableTxnRecord.class, ExpirableTxnRecord::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(TxnReceipt.class, TxnReceipt::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(TxnId.class, TxnId::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(CurrencyAdjustments.class, CurrencyAdjustments::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(EvmFnResult.class, EvmFnResult::new));
    for (String dumpLoc : accountsLocs) {
        PojoLedger.fromDisk(dumpLoc).asJsonTo(jsonSuffixed(dumpLoc));
    }
}
Also used : ExpirableTxnRecord(com.hedera.services.state.submerkle.ExpirableTxnRecord) FCQueue(com.swirlds.fcqueue.FCQueue) TxnReceipt(com.hedera.services.legacy.core.jproto.TxnReceipt) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) MerkleEntityId(com.hedera.services.state.merkle.MerkleEntityId) MerkleAccountState(com.hedera.services.state.merkle.MerkleAccountState) MerkleLong(com.swirlds.common.merkle.utility.MerkleLong) EntityId(com.hedera.services.state.submerkle.EntityId) MerkleEntityId(com.hedera.services.state.merkle.MerkleEntityId) TxnId(com.hedera.services.state.submerkle.TxnId) EvmFnResult(com.hedera.services.state.submerkle.EvmFnResult) CurrencyAdjustments(com.hedera.services.state.submerkle.CurrencyAdjustments) ClassConstructorPair(com.swirlds.common.constructable.ClassConstructorPair) Test(org.junit.jupiter.api.Test)

Example 8 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class BasicTransactionContextTest method buildExpectedRecord.

private ExpirableTxnRecord.Builder buildExpectedRecord(long otherNonThresholdFees, byte[] hash, TxnAccessor accessor, Instant consensusTime, TxnReceipt receipt) {
    long amount = narratedCharging.totalFeesChargedToPayer() + otherNonThresholdFees;
    TransferList transfersList = transfers;
    List<TokenTransferList> tokenTransferList = List.of(tokenTransfers);
    var builder = ExpirableTxnRecord.newBuilder().setReceipt(receipt).setTxnHash(hash).setTxnId(TxnId.fromGrpc(accessor.getTxnId())).setConsensusTime(RichInstant.fromJava(consensusTime)).setMemo(accessor.getTxn().getMemo()).setFee(amount).setTransferList(!transfersList.getAccountAmountsList().isEmpty() ? CurrencyAdjustments.fromGrpc(transfersList) : null).setScheduleRef(accessor.isTriggeredTxn() ? fromGrpcScheduleId(accessor.getScheduleRef()) : null).setNewTokenAssociations(newTokenAssociations);
    List<EntityId> tokens = new ArrayList<>();
    List<CurrencyAdjustments> tokenAdjustments = new ArrayList<>();
    for (TokenTransferList tokenTransfers : tokenTransferList) {
        tokens.add(EntityId.fromGrpcTokenId(tokenTransfers.getToken()));
        tokenAdjustments.add(CurrencyAdjustments.fromGrpc(tokenTransfers.getTransfersList()));
    }
    builder.setTokens(tokens).setTokenAdjustments(tokenAdjustments);
    return builder;
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) ArrayList(java.util.ArrayList) CurrencyAdjustments(com.hedera.services.state.submerkle.CurrencyAdjustments) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) TransferList(com.hederahashgraph.api.proto.java.TransferList)

Example 9 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class MerkleTopicTest method assertDefaultTopicAccessors.

/**
 * Assert that all the accessors for topic return default values.
 *
 * @param merkleTopic
 */
private void assertDefaultTopicAccessors(final MerkleTopic merkleTopic) {
    assertFalse(merkleTopic.hasMemo());
    assertEquals("", merkleTopic.getMemo());
    assertFalse(merkleTopic.hasAdminKey());
    assertTrue(merkleTopic.getAdminKey().isEmpty());
    assertFalse(merkleTopic.hasSubmitKey());
    assertTrue(merkleTopic.getSubmitKey().isEmpty());
    assertEquals(0L, merkleTopic.getAutoRenewDurationSeconds());
    assertFalse(merkleTopic.hasAutoRenewAccountId());
    assertEquals(new EntityId(), merkleTopic.getAutoRenewAccountId());
    assertFalse(merkleTopic.hasExpirationTimestamp());
    assertEquals(new RichInstant(), merkleTopic.getExpirationTimestamp());
    assertFalse(merkleTopic.isDeleted());
    assertEquals(0L, merkleTopic.getSequenceNumber());
    assertFalse(merkleTopic.hasRunningHash());
    assertArrayEquals(new byte[48], merkleTopic.getRunningHash());
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) RichInstant(com.hedera.services.state.submerkle.RichInstant)

Example 10 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class TypedTokenStore method mapModelChanges.

private void mapModelChanges(Token token, MerkleToken mutableToken) {
    final var newAutoRenewAccount = token.getAutoRenewAccount();
    if (newAutoRenewAccount != null) {
        mutableToken.setAutoRenewAccount(new EntityId(newAutoRenewAccount.getId()));
        mutableToken.setAutoRenewPeriod(token.getAutoRenewPeriod());
    }
    mutableToken.setTreasury(new EntityId(token.getTreasury().getId()));
    mutableToken.setTotalSupply(token.getTotalSupply());
    mutableToken.setAccountsFrozenByDefault(token.isFrozenByDefault());
    mutableToken.setLastUsedSerialNumber(token.getLastUsedSerialNumber());
    mutableToken.setTokenType(token.getType());
    mutableToken.setSupplyType(token.getSupplyType());
    mutableToken.setMemo(token.getMemo());
    mutableToken.setAdminKey(token.getAdminKey());
    mutableToken.setSupplyKey(token.getSupplyKey());
    mutableToken.setWipeKey(token.getWipeKey());
    mutableToken.setFreezeKey(token.getFreezeKey());
    mutableToken.setKycKey(token.getKycKey());
    mutableToken.setFeeScheduleKey(token.getFeeScheduleKey());
    mutableToken.setPauseKey(token.getPauseKey());
    mutableToken.setMaxSupply(token.getMaxSupply());
    mutableToken.setDeleted(token.isDeleted());
    mutableToken.setPaused(token.isPaused());
    if (token.getCustomFees() != null) {
        mutableToken.setFeeSchedule(token.getCustomFees());
    }
    mutableToken.setExpiry(token.getExpiry());
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId)

Aggregations

EntityId (com.hedera.services.state.submerkle.EntityId)35 Test (org.junit.jupiter.api.Test)18 MerkleToken (com.hedera.services.state.merkle.MerkleToken)9 RichInstant (com.hedera.services.state.submerkle.RichInstant)6 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)5 ExpirableTxnRecord (com.hedera.services.state.submerkle.ExpirableTxnRecord)5 TxnId (com.hedera.services.state.submerkle.TxnId)4 EntityNum (com.hedera.services.utils.EntityNum)4 ClassConstructorPair (com.swirlds.common.constructable.ClassConstructorPair)4 TxnReceipt (com.hedera.services.legacy.core.jproto.TxnReceipt)3 MerkleAccountState (com.hedera.services.state.merkle.MerkleAccountState)3 MerkleTopic (com.hedera.services.state.merkle.MerkleTopic)3 CurrencyAdjustments (com.hedera.services.state.submerkle.CurrencyAdjustments)3 ScheduleStore (com.hedera.services.store.schedule.ScheduleStore)3 AccountID (com.hederahashgraph.api.proto.java.AccountID)3 ByteString (com.google.protobuf.ByteString)2 JKeyList (com.hedera.services.legacy.core.jproto.JKeyList)2 MerkleEntityId (com.hedera.services.state.merkle.MerkleEntityId)2 MerkleUniqueToken (com.hedera.services.state.merkle.MerkleUniqueToken)2 DomainSerdes (com.hedera.services.state.serdes.DomainSerdes)2