This commit is contained in:
Yusef Napora 2019-11-08 11:42:36 -05:00
parent 2ebfd9d4f2
commit c016eb5a80
3 changed files with 12 additions and 12 deletions

View File

@ -20,11 +20,11 @@ type SignedEnvelope struct {
// A binary identifier that indicates what kind of data is contained in the payload. // A binary identifier that indicates what kind of data is contained in the payload.
// TODO(yusef): enforce multicodec prefix // TODO(yusef): enforce multicodec prefix
TypeHint []byte TypeHint []byte
// The envelope payload. This is private to discourage accessing the payload without verifying the signature. // The envelope payload. This is private to discourage accessing the payload without verifying the signature.
// To access, use the Open method. // To access, use the Open method.
contents []byte contents []byte
// The signature of the domain string, type hint, and contents. // The signature of the domain string, type hint, and contents.
signature []byte signature []byte
@ -91,8 +91,8 @@ func (e *SignedEnvelope) Marshal() ([]byte, error) {
} }
msg := pb.SignedEnvelope{ msg := pb.SignedEnvelope{
PublicKey: key, PublicKey: key,
TypeHint: e.TypeHint, TypeHint: e.TypeHint,
Contents: e.contents, Contents: e.contents,
Signature: e.signature, Signature: e.signature,
} }
return proto.Marshal(&msg) return proto.Marshal(&msg)
@ -136,4 +136,4 @@ func encodedSize(content []byte) []byte {
b := make([]byte, 8) b := make([]byte, 8)
binary.BigEndian.PutUint64(b, uint64(len(content))) binary.BigEndian.PutUint64(b, uint64(len(content)))
return b return b
} }

View File

@ -147,4 +147,4 @@ func TestEnvelopeValidateFailsIfContentsAreAltered(t *testing.T) {
if valid { if valid {
t.Error("envelope should be invalid, but Valid returns true") t.Error("envelope should be invalid, but Valid returns true")
} }
} }

View File

@ -5,8 +5,8 @@ import (
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
"github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
ma "github.com/multiformats/go-multiaddr"
pb "github.com/libp2p/go-libp2p-core/routing/pb" pb "github.com/libp2p/go-libp2p-core/routing/pb"
ma "github.com/multiformats/go-multiaddr"
"time" "time"
) )
@ -47,8 +47,8 @@ func RoutingStateFromAddrInfo(info *peer.AddrInfo) *RoutingState {
annotated[i] = &AnnotatedAddr{Multiaddr: a} annotated[i] = &AnnotatedAddr{Multiaddr: a}
} }
return &RoutingState{ return &RoutingState{
PeerID: info.ID, PeerID: info.ID,
Seq: statelessSeqNo(), Seq: statelessSeqNo(),
Addresses: annotated, Addresses: annotated,
} }
} }
@ -106,8 +106,8 @@ func (s *RoutingState) Marshal() ([]byte, error) {
return nil, err return nil, err
} }
msg := pb.RoutingStateRecord{ msg := pb.RoutingStateRecord{
PeerId: id, PeerId: id,
Seq: s.Seq, Seq: s.Seq,
Addresses: addrsToProtobuf(s.Addresses), Addresses: addrsToProtobuf(s.Addresses),
} }
return proto.Marshal(&msg) return proto.Marshal(&msg)
@ -147,4 +147,4 @@ func addrsToProtobuf(addrs []*AnnotatedAddr) []*pb.RoutingStateRecord_AddressInf
out = append(out, &pb.RoutingStateRecord_AddressInfo{Multiaddr: addr.Bytes()}) out = append(out, &pb.RoutingStateRecord_AddressInfo{Multiaddr: addr.Bytes()})
} }
return out return out
} }