Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
feat(json): provide JSON marshal/unmashal functions for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
laser committed Sep 20, 2019
1 parent 67a3da8 commit 0151d38
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ func (s *SortedSectorInfo) Values() []SectorInfo {
return s.f
}

// MarshalJSON JSON-encodes and serializes the SortedSectorInfo.
func (s SortedSectorInfo) MarshalJSON() ([]byte, error) {
return json.Marshal(s.f)
}

// UnmarshalJSON parses the JSON-encoded byte slice and stores the result in the
// value pointed to by s.f. Note that this method allows for construction of a
// SortedSectorInfo which violates its invariant (that its SectorInfo are sorted
// in some defined way). Callers should take care to never provide a byte slice
// which would violate this invariant.
func (s *SortedSectorInfo) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &s.f)
}

type SectorInfo struct {
SectorID uint64
CommR [CommitmentBytesLen]byte
Expand Down

0 comments on commit 0151d38

Please sign in to comment.