Merge pull request #763 from MichaelMure/resolve-entity

entity: allow to resolve identities when numashalling operations
This commit is contained in:
Michael Muré 2022-03-10 16:56:46 +01:00 committed by GitHub
commit 069a4c975f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View File

@ -71,7 +71,7 @@ func idOperation(op Operation, base *OpBase) entity.Id {
return base.id
}
func operationUnmarshaller(author identity.Interface, raw json.RawMessage) (dag.Operation, error) {
func operationUnmarshaller(author identity.Interface, raw json.RawMessage, resolver identity.Resolver) (dag.Operation, error) {
var t struct {
OperationType OperationType `json:"type"`
}

View File

@ -67,7 +67,7 @@ func (o *op2) Author() identity.Interface {
return o.author
}
func unmarshaler(author identity.Interface, raw json.RawMessage) (Operation, error) {
func unmarshaler(author identity.Interface, raw json.RawMessage, resolver identity.Resolver) (Operation, error) {
var t struct {
OperationType int `json:"type"`
}

View File

@ -26,7 +26,7 @@ type Definition struct {
// the Namespace in git references (bugs, prs, ...)
Namespace string
// a function decoding a JSON message into an Operation
OperationUnmarshaler func(author identity.Interface, raw json.RawMessage) (Operation, error)
OperationUnmarshaler func(author identity.Interface, raw json.RawMessage, resolver identity.Resolver) (Operation, error)
// the expected format version number, that can be used for data migration/upgrade
FormatVersion uint
}

View File

@ -314,7 +314,7 @@ func unmarshallPack(def Definition, resolver identity.Resolver, data []byte) ([]
for _, raw := range aux.Operations {
// delegate to specialized unmarshal function
op, err := def.OperationUnmarshaler(author, raw)
op, err := def.OperationUnmarshaler(author, raw, resolver)
if err != nil {
return nil, nil, err
}