Skip to content

Commit

Permalink
Merge pull request #702 from bstasyszyn/operationprops
Browse files Browse the repository at this point in the history
feat: Added Type and Properties to Operation
  • Loading branch information
bstasyszyn authored Jun 22, 2023
2 parents cca19f8 + b5931bc commit a1b968a
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 a1b968a

Please sign in to comment.