Skip to content

Commit

Permalink
feat: Added Type and Properties to Operation
Browse files Browse the repository at this point in the history
Added two fields:
- Type: The type of operation (create, update, recover, etc.)
- Properties: An arbitrary set of properties of the operation

Signed-off-by: Bob Stasyszyn <[email protected]>
  • Loading branch information
bstasyszyn committed Jun 22, 2023
1 parent cca19f8 commit b5931bc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/api/operation/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ SPDX-License-Identifier: Apache-2.0

package operation

// Property contains a key-value pair.
type Property struct {
Key string
Value interface{}
}

// Operation holds minimum information required for parsing/validating client request.
type Operation struct {

Expand All @@ -23,6 +29,9 @@ type Operation struct {

// AnchorOrigin defines anchor origin.
AnchorOrigin interface{}

// Properties contains an arbitrary set of implementation-specific name-value pairs.
Properties []Property
}

// Reference holds minimum information about did operation (suffix and type).
Expand Down Expand Up @@ -90,10 +99,12 @@ const (

// QueuedOperation stores minimum required operation info for operations queue.
type QueuedOperation struct {
Type Type
OperationRequest []byte
UniqueSuffix string
Namespace string
AnchorOrigin interface{}
Properties []Property
}

// QueuedOperationAtTime contains queued operation info with protocol genesis time.
Expand Down
2 changes: 2 additions & 0 deletions pkg/batch/cutter/cutter.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ func getOperationsAtProtocolVersion(opsAtTime []*operation.QueuedOperationAtTime

ops = append(ops,
&operation.QueuedOperation{
Type: op.Type,
OperationRequest: op.OperationRequest,
UniqueSuffix: op.UniqueSuffix,
Namespace: op.Namespace,
Properties: op.Properties,
},
)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/dochandler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,12 @@ func (r *DocumentHandler) resolveRequestWithInitialState(uniqueSuffix, longFormD
func (r *DocumentHandler) addToBatch(op *operation.Operation, versionTime uint64) error {
return r.writer.Add(
&operation.QueuedOperation{
Type: op.Type,
Namespace: r.namespace,
UniqueSuffix: op.UniqueSuffix,
OperationRequest: op.OperationRequest,
AnchorOrigin: op.AnchorOrigin,
Properties: op.Properties,
}, versionTime)
}

Expand Down

0 comments on commit b5931bc

Please sign in to comment.