diff options
Diffstat (limited to 'internal/storage/store.go')
| -rw-r--r-- | internal/storage/store.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/storage/store.go b/internal/storage/store.go new file mode 100644 index 0000000..59055b7 --- /dev/null +++ b/internal/storage/store.go @@ -0,0 +1,46 @@ +package storage + +import "github.com/Fuwn/plutia/internal/types" + +type BlockHashEntry struct { + BlockID uint64 + Hash string +} + +type OperationMutation struct { + State types.StateV1 + Ref *types.BlockRefV1 +} + +type Store interface { + Close() error + + GetMode() (string, error) + SetMode(mode string) error + + GetGlobalSeq() (uint64, error) + SetGlobalSeq(seq uint64) error + + PutState(state types.StateV1) error + GetState(did string) (types.StateV1, bool, error) + ListStates() ([]types.StateV1, error) + ForEachState(fn func(types.StateV1) error) error + ApplyOperationsBatch(ops []OperationMutation, blockHashes []BlockHashEntry) error + + SetChainHead(did string, seq uint64) error + GetChainHead(did string) (uint64, bool, error) + AddDIDSequence(did string, seq uint64) error + ListDIDSequences(did string) ([]uint64, error) + + PutOpSeqRef(seq uint64, ref types.BlockRefV1) error + GetOpSeqRef(seq uint64) (types.BlockRefV1, bool, error) + + PutBlockHash(blockID uint64, hash string) error + GetBlockHash(blockID uint64) (string, bool, error) + ListBlockHashes() ([]string, error) + ListBlockHashEntries() ([]BlockHashEntry, error) + + PutCheckpoint(cp types.CheckpointV1) error + GetCheckpoint(sequence uint64) (types.CheckpointV1, bool, error) + GetLatestCheckpoint() (types.CheckpointV1, bool, error) +} |