All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.casper.sdk.model.key.ByteCodeAddr Maven / Gradle / Ivy

Go to download

SDK to streamline the 3rd party Java client integration processes. Such 3rd parties include exchanges & app developers.

The newest version!
package com.casper.sdk.model.key;

import com.casper.sdk.exception.NoSuchKeyTagException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * An address for ByteCode records stored in global state.
 *
 * @author [email protected]
 */
@AllArgsConstructor
@Getter
public enum ByteCodeAddr {

    /** An address for byte code to be executed against the V1 Casper execution engine. */
    V1_CASPER_WASM((byte) 0, "v1-wasm"),
    /** An empty byte code record */
    EMPTY((byte) 1, "empty");

    private final byte byteTag;
    private final String keyName;

    public static ByteCodeAddr getByTag(byte tag) throws NoSuchKeyTagException {
        for (ByteCodeAddr a : values()) {
            if (a.byteTag == tag)
                return a;
        }
        throw new NoSuchKeyTagException();
    }

    public static ByteCodeAddr getByKeyName(String keyName) {
        for (ByteCodeAddr entityAddr: values()) {
            if (keyName.contains(entityAddr.keyName)) {
                return entityAddr;
            }
        }
       throw new IllegalArgumentException("No such key name: " + keyName);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy