module arch.node.engines.local_key_value_storage_messages;

import prelude open;

syntax alias StorageKey := String;
syntax alias StorageValue := String;
syntax alias EpochTimestamp := Nat;

type GetValueKVStoreRequest :=
  mkGetValueKVStoreRequest@{
    key : StorageKey;
  };

type GetValueKVStoreReply :=
  mkGetValueKVStoreReply@{
    key : StorageKey;
    value : StorageValue;
  };

type SetValueKVStoreRequest :=
  mkSetValueKVStoreRequest@{
    key : StorageKey;
    value : StorageValue;
  };

type SetValueKVStoreReply :=
  mkSetValueKVStoreReply@{
    key : StorageKey;
    success : Bool;
  };

type DeleteValueKVStoreRequest :=
  mkDeleteValueKVStoreRequest@{
    key : StorageKey;
  };

type DeleteValueKVStoreReply :=
  mkDeleteValueKVStoreReply@{
    key : StorageKey;
    success : Bool;
  };

type ValueChangedKVStore :=
  mkValueChangedKVStore@{
    key : StorageKey;
    value : StorageValue;
    timestamp : EpochTimestamp;
  };

type LocalKVStorageMsg :=
  | LocalKVStorageMsgGetValueRequest GetValueKVStoreRequest
  | LocalKVStorageMsgGetValueReply GetValueKVStoreReply
  | LocalKVStorageMsgSetValueRequest SetValueKVStoreRequest
  | LocalKVStorageMsgSetValueReply SetValueKVStoreReply
  | LocalKVStorageMsgDeleteValueRequest DeleteValueKVStoreRequest
  | LocalKVStorageMsgDeleteValueReply DeleteValueKVStoreReply
  | LocalKVStorageMsgValueChanged ValueChangedKVStore;