Skip to content

Commit

Permalink
feat: add json marshaler interface to log's entry interface
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton authored and jefft0 committed Nov 29, 2023
1 parent 9b342ba commit 1efd55a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions entry/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,14 @@ func (e *Entry) IsParent(b iface.IPFSLogEntry) bool {
return false
}

func (e *Entry) MarshalJSON() ([]byte, error) {
return json.Marshal(e)
}

func (e *Entry) UnmarshalJSON(payload []byte) error {
return json.Unmarshal(payload, e)
}

// FindChildren finds an entry's children from an Array of entries.
//
// Returns entry's children as an Array up to the last know child.
Expand Down
5 changes: 5 additions & 0 deletions iface/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package iface

import (
"context"
"encoding/json"
"time"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -173,6 +174,10 @@ type IPFSLogEntry interface {
Equals(b IPFSLogEntry) bool
IsParent(b IPFSLogEntry) bool
Defined() bool

// marshaler
json.Marshaler
json.Unmarshaler
}

type IPFSLogLamportClock interface {
Expand Down

0 comments on commit 1efd55a

Please sign in to comment.