github.com/decred/dcrlnd@v0.7.6/channeldb/migration20/codec.go (about) 1 package migration20 2 3 import ( 4 "encoding/binary" 5 "io" 6 7 "github.com/decred/dcrd/wire" 8 ) 9 10 var ( 11 byteOrder = binary.BigEndian 12 ) 13 14 // writeOutpoint writes an outpoint from the passed writer. 15 func writeOutpoint(w io.Writer, o *wire.OutPoint) error { 16 if _, err := w.Write(o.Hash[:]); err != nil { 17 return err 18 } 19 if err := binary.Write(w, byteOrder, o.Index); err != nil { 20 return err 21 } 22 23 // Note(decred): This is missing the tree. 24 25 return nil 26 } 27 28 // readOutpoint reads an outpoint from the passed reader. 29 func readOutpoint(r io.Reader, o *wire.OutPoint) error { 30 if _, err := io.ReadFull(r, o.Hash[:]); err != nil { 31 return err 32 } 33 if err := binary.Read(r, byteOrder, &o.Index); err != nil { 34 return err 35 } 36 37 // Note(decred): This is missing the tree. 38 39 return nil 40 }