Search in sources :

Example 6 with PrecompiledDataWord

use of org.aion.precompiled.type.PrecompiledDataWord in project aion by aionnetwork.

the class BridgeStorageConnector method getBundle.

/**
 * @implNote changed as part of ATB-4, see {@link #setBundle(byte[], byte[])} above for more
 *     information.
 * @implNote note here that we return an EMPTY_WORD, this is checked in the controller layer and
 *     equates to a false.
 * @param key bundleHash
 * @return {@code EMPTY_WORD (32)} if no blockHash is found, {@code transactionHash} of the
 *     input transaction otherwise.
 */
public byte[] getBundle(@Nonnull final byte[] key) {
    assert key.length == 32;
    byte[] h = ByteUtil.chop(CapabilitiesProvider.getExternalCapabilities().blake2b(ByteUtil.merge(M_ID.BUNDLE_MAP.id, key)));
    PrecompiledDataWord hWord = PrecompiledDataWord.fromBytes(h);
    byte[] bundleDoubleWord = this.getDWORD(hWord);
    if (bundleDoubleWord == null)
        return ByteUtil.EMPTY_WORD;
    // paranoid, this should typically never happen
    if (bundleDoubleWord.length < 32)
        bundleDoubleWord = PrecompiledUtilities.pad(bundleDoubleWord, 32);
    return bundleDoubleWord;
}
Also used : PrecompiledDataWord(org.aion.precompiled.type.PrecompiledDataWord) IPrecompiledDataWord(org.aion.precompiled.type.IPrecompiledDataWord)

Example 7 with PrecompiledDataWord

use of org.aion.precompiled.type.PrecompiledDataWord in project aion by aionnetwork.

the class BridgeStorageConnector method setInitialized.

public void setInitialized(final boolean initialized) {
    PrecompiledDataWord init = initialized ? PrecompiledDataWord.fromInt(1) : PrecompiledDataWord.fromInt(0);
    this.setWORD(S_OFFSET.INITIALIZED.offset, init);
}
Also used : PrecompiledDataWord(org.aion.precompiled.type.PrecompiledDataWord) IPrecompiledDataWord(org.aion.precompiled.type.IPrecompiledDataWord)

Aggregations

IPrecompiledDataWord (org.aion.precompiled.type.IPrecompiledDataWord)7 PrecompiledDataWord (org.aion.precompiled.type.PrecompiledDataWord)7 BigInteger (java.math.BigInteger)1 PrecompiledTransactionResult (org.aion.precompiled.PrecompiledTransactionResult)1 IExternalCapabilitiesForPrecompiled (org.aion.precompiled.type.IExternalCapabilitiesForPrecompiled)1 AionAddress (org.aion.types.AionAddress)1