Skip to content

Commit 9eb4700

Browse files
authored
Merge pull request #2 from filecoin-project/feat/marshal-binary
Added standard (un)marshalBinary methods
2 parents da8eea2 + c2a28d5 commit 9eb4700

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

address.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,19 @@ func hash(ingest []byte, cfg *blake2b.Config) []byte {
355355
return hasher.Sum(nil)
356356
}
357357

358+
func (a Address) MarshalBinary() ([]byte, error) {
359+
return a.Bytes(), nil
360+
}
361+
362+
func (a *Address) UnmarshalBinary(b []byte) error {
363+
newAddr, err := NewFromBytes(b)
364+
if err != nil {
365+
return err
366+
}
367+
*a = newAddr
368+
return nil
369+
}
370+
358371
func (a Address) MarshalCBOR(w io.Writer) error {
359372
if a == Undef {
360373
return fmt.Errorf("cannot marshal undefined address")

0 commit comments

Comments
 (0)