|
|
|
@ -70,17 +70,17 @@ class Storage:
|
|
|
|
|
if sectrue != self.lib.storage_set(c.c_uint16(key), val, c.c_uint16(len(val))):
|
|
|
|
|
raise RuntimeError("Failed to set value in storage.")
|
|
|
|
|
|
|
|
|
|
def set_counter(self, key: int, count: int) -> bool:
|
|
|
|
|
return sectrue == self.lib.storage_set_counter(
|
|
|
|
|
def set_counter(self, key: int, count: int) -> None:
|
|
|
|
|
if count > 0xFFFF_FFFF or sectrue != self.lib.storage_set_counter(
|
|
|
|
|
c.c_uint16(key), c.c_uint32(count)
|
|
|
|
|
)
|
|
|
|
|
):
|
|
|
|
|
raise RuntimeError("Failed to set value in storage.")
|
|
|
|
|
|
|
|
|
|
def next_counter(self, key: int) -> int:
|
|
|
|
|
count = c.c_uint32()
|
|
|
|
|
if sectrue == self.lib.storage_next_counter(c.c_uint16(key), c.byref(count)):
|
|
|
|
|
return count.value
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
if sectrue != self.lib.storage_next_counter(c.c_uint16(key), c.byref(count)):
|
|
|
|
|
raise RuntimeError("Failed to set value in storage.")
|
|
|
|
|
return count.value
|
|
|
|
|
|
|
|
|
|
def delete(self, key: int) -> bool:
|
|
|
|
|
return sectrue == self.lib.storage_delete(c.c_uint16(key))
|
|
|
|
|