public class Storage
extends java.lang.Object
Most methods in Storage are available in a version that requires a StorageContext as parameter and a version that doesn't. On multiple consecutive calls to
Storage methods, it makes sense to retrieve the StorageContext once and reuse
it in each call. This saves GAS because the Syscall for getting the
StorageContext is only called once and not with every Storage method
invocation.
| Constructor and Description |
|---|
Storage() |
| Modifier and Type | Method and Description |
|---|---|
static void |
delete(byte[] key)
Deletes the value corresponding to the given key from the storage.
|
static void |
delete(StorageContext context,
byte[] key)
Deletes the value corresponding to the given key from the storage.
|
static void |
delete(StorageContext context,
java.lang.String key)
Deletes the value corresponding to the given key from the storage.
|
static void |
delete(java.lang.String key)
Deletes the value corresponding to the given key from the storage.
|
static Iterator<byte[],byte[]> |
find(byte[] prefix)
Returns an iterator over the values found under the given key prefix.
|
static Iterator<byte[],byte[]> |
find(StorageContext context,
byte[] prefix)
Returns an iterator over the values found under the given key prefix.
|
static Iterator<java.lang.String,byte[]> |
find(StorageContext context,
java.lang.String prefix)
Returns an iterator over the values found under the given key prefix.
|
static Iterator<java.lang.String,byte[]> |
find(java.lang.String prefix)
Returns an iterator over the values found under the given key prefix.
|
static byte[] |
get(byte[] key)
Returns the value corresponding to the given key.
|
static byte[] |
get(StorageContext context,
byte[] key)
Returns the value corresponding to the given key.
|
static byte[] |
get(StorageContext context,
java.lang.String key)
Returns the value corresponding to the given key.
|
static byte[] |
get(java.lang.String key)
Returns the value corresponding to the given key.
|
static StorageContext |
getReadOnlyContext()
Returns the storage context of the contract in read-only mode.
|
static StorageContext |
getStorageContext()
Returns the storage context of the contract.
|
static void |
put(byte[] key,
byte[] value)
Stores the given key-value pair.
|
static void |
put(byte[] key,
int value)
Stores the given key-value pair.
|
static void |
put(byte[] key,
long value)
Stores the given key-value pair.
|
static void |
put(byte[] key,
java.lang.String value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
byte[] key,
byte[] value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
byte[] key,
int value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
byte[] key,
long value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
byte[] key,
java.lang.String value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
java.lang.String key,
byte[] value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
java.lang.String key,
int value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
java.lang.String key,
long value)
Stores the given key-value pair.
|
static void |
put(StorageContext context,
java.lang.String key,
java.lang.String value)
Stores the given key-value pair.
|
static void |
put(java.lang.String key,
byte[] value)
Stores the given key-value pair.
|
static void |
put(java.lang.String key,
int value)
Stores the given key-value pair.
|
static void |
put(java.lang.String key,
long value)
Stores the given key-value pair.
|
static void |
put(java.lang.String key,
java.lang.String value)
Stores the given key-value pair.
|
static void |
putEx(byte[] key,
byte[] value,
byte storageFlag)
Stores the given key-value pair using the given
StorageFlags. |
static void |
putEx(byte[] key,
int value,
byte storageFlag)
Stores the given key-value pair using the the given
StorageFlags. |
static void |
putEx(byte[] key,
long value,
byte storageFlag)
Stores the given key-value pair using the the given
StorageFlags. |
static void |
putEx(byte[] key,
java.lang.String value,
byte storageFlag)
Stores the given key-value pair using the the given
StorageFlags. |
static void |
putEx(java.lang.String key,
byte[] value,
byte storageFlag)
Stores the given key-value pair using the the given
StorageFlags. |
static void |
putEx(java.lang.String key,
int value,
byte storageFlag)
Stores the given key-value pair using the the given
StorageFlags. |
static void |
putEx(java.lang.String key,
long value,
byte storageFlag)
Stores the given key-value pair using the the given
StorageFlags. |
static void |
putEx(java.lang.String key,
java.lang.String value,
byte storageFlag)
Stores the given key-value pair using the the given
StorageFlags. |
public static StorageContext getStorageContext()
public static StorageContext getReadOnlyContext()
public static byte[] get(StorageContext context, byte[] key)
context - The storage context to search in.key - The key to search for.public static byte[] get(StorageContext context, java.lang.String key)
context - The storage context to search in.key - The key to search for.public static void put(StorageContext context, byte[] key, byte[] value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void put(StorageContext context, byte[] key, int value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void put(StorageContext context, byte[] key, long value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void put(StorageContext context, byte[] key, java.lang.String value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void put(StorageContext context, java.lang.String key, byte[] value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void put(StorageContext context, java.lang.String key, int value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void put(StorageContext context, java.lang.String key, long value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void put(StorageContext context, java.lang.String key, java.lang.String value)
context - The storage context to store the value in.key - The key.value - The value to store.public static void delete(StorageContext context, byte[] key)
context - The storage context to delete from.key - The key to delete.public static void delete(StorageContext context, java.lang.String key)
context - The storage context to delete from.key - The key to delete.public static Iterator<byte[],byte[]> find(StorageContext context, byte[] prefix)
context - The storage context to get the values from.prefix - The key prefix.public static Iterator<java.lang.String,byte[]> find(StorageContext context, java.lang.String prefix)
context - The storage context to get the values from.prefix - The key prefix.public static byte[] get(byte[] key)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key to search for.public static byte[] get(java.lang.String key)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key to search for.public static void put(byte[] key,
byte[] value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void put(byte[] key,
int value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void put(byte[] key,
long value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void putEx(byte[] key,
byte[] value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void putEx(byte[] key,
int value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void putEx(byte[] key,
long value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void put(byte[] key,
java.lang.String value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void putEx(byte[] key,
java.lang.String value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void put(java.lang.String key,
byte[] value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void putEx(java.lang.String key,
byte[] value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void putEx(java.lang.String key,
int value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void putEx(java.lang.String key,
long value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void put(java.lang.String key,
int value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void put(java.lang.String key,
long value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void put(java.lang.String key,
java.lang.String value)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.public static void putEx(java.lang.String key,
java.lang.String value,
byte storageFlag)
StorageFlags.
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key.value - The value to store.storageFlag - The storage flags to use.public static void delete(byte[] key)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key to delete.public static void delete(java.lang.String key)
Implicitly makes a Syscall to retrieve the current contract's storage context.
key - The key to delete.public static Iterator<byte[],byte[]> find(byte[] prefix)
Implicitly makes a Syscall to retrieve the current contract's storage context.
prefix - The key prefix.public static Iterator<java.lang.String,byte[]> find(java.lang.String prefix)
Implicitly makes a Syscall to retrieve the current contract's storage context.
prefix - The key prefix.