lnwire: replace instances of *btcec.PublicKey with [33]byte in ann messages

In this commit, we replace all instances of *btcec.PublicKey within the
announcement messages with a simple [33]byte. We do this as usually we
don’t need to immediately validate an announcement, therefore we can
avoid the scalar multiplications during decoding.
This commit is contained in:
Olaoluwa Osuntokun
2018-01-30 19:53:49 -08:00
parent 4dd108c827
commit aa2e91f7c4
4 changed files with 113 additions and 31 deletions

View File

@@ -201,6 +201,10 @@ func writeElement(w io.Writer, element interface{}) error {
return err
}
if _, err := w.Write(e[:]); err != nil {
return err
}
case [33]byte:
if _, err := w.Write(e[:]); err != nil {
return err
}
@@ -527,6 +531,10 @@ func readElement(r io.Reader, element interface{}) error {
if _, err := io.ReadFull(r, *e); err != nil {
return err
}
case *[33]byte:
if _, err := io.ReadFull(r, e[:]); err != nil {
return err
}
case []byte:
if _, err := io.ReadFull(r, e); err != nil {
return err