channeldb: export route serialization
This commit is contained in:
parent
67ddb72eab
commit
eb4e65e54f
@ -484,7 +484,7 @@ func serializePaymentAttemptInfo(w io.Writer, a *PaymentAttemptInfo) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := serializeRoute(w, a.Route); err != nil {
|
||||
if err := SerializeRoute(w, a.Route); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ func deserializePaymentAttemptInfo(r io.Reader) (*PaymentAttemptInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.Route, err = deserializeRoute(r)
|
||||
a.Route, err = DeserializeRoute(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -533,7 +533,8 @@ func deserializeHop(r io.Reader) (*route.Hop, error) {
|
||||
return h, nil
|
||||
}
|
||||
|
||||
func serializeRoute(w io.Writer, r route.Route) error {
|
||||
// SerializeRoute serializes a route.
|
||||
func SerializeRoute(w io.Writer, r route.Route) error {
|
||||
if err := WriteElements(w,
|
||||
r.TotalTimeLock, r.TotalAmount, r.SourcePubKey[:],
|
||||
); err != nil {
|
||||
@ -553,7 +554,8 @@ func serializeRoute(w io.Writer, r route.Route) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func deserializeRoute(r io.Reader) (route.Route, error) {
|
||||
// DeserializeRoute deserializes a route.
|
||||
func DeserializeRoute(r io.Reader) (route.Route, error) {
|
||||
rt := route.Route{}
|
||||
if err := ReadElements(r,
|
||||
&rt.TotalTimeLock, &rt.TotalAmount,
|
||||
|
@ -203,12 +203,12 @@ func TestRouteSerialization(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var b bytes.Buffer
|
||||
if err := serializeRoute(&b, testRoute); err != nil {
|
||||
if err := SerializeRoute(&b, testRoute); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
r := bytes.NewReader(b.Bytes())
|
||||
route2, err := deserializeRoute(r)
|
||||
route2, err := DeserializeRoute(r)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user