Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add json marshaler interface to log's entry interface #58

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading