mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2024-12-27 23:40:11 +08:00
rename Equals -> Equal, add some comments
This commit is contained in:
parent
295e3eca01
commit
08da615203
@ -109,6 +109,7 @@ func (e *SignedEnvelope) Payload() []byte {
|
||||
return e.payload
|
||||
}
|
||||
|
||||
// Marshal returns a byte slice containing a serailized protobuf representation of a SignedEnvelope.
|
||||
func (e *SignedEnvelope) Marshal() ([]byte, error) {
|
||||
key, err := PublicKeyToProto(e.publicKey)
|
||||
if err != nil {
|
||||
@ -123,7 +124,10 @@ func (e *SignedEnvelope) Marshal() ([]byte, error) {
|
||||
return proto.Marshal(&msg)
|
||||
}
|
||||
|
||||
func (e *SignedEnvelope) Equals(other *SignedEnvelope) bool {
|
||||
// Equal returns true if the other SignedEnvelope has the same
|
||||
// public key, payload, payload type, and signature. This
|
||||
// implies that they were also created with the same domain string.
|
||||
func (e *SignedEnvelope) Equal(other *SignedEnvelope) bool {
|
||||
return e.publicKey.Equals(other.publicKey) &&
|
||||
bytes.Compare(e.payloadType, other.payloadType) == 0 &&
|
||||
bytes.Compare(e.payload, other.payload) == 0 &&
|
||||
|
@ -45,7 +45,7 @@ func TestEnvelopeHappyPath(t *testing.T) {
|
||||
t.Error("payload of envelope does not match input")
|
||||
}
|
||||
|
||||
if !envelope.Equals(deserialized) {
|
||||
if !envelope.Equal(deserialized) {
|
||||
t.Error("round-trip serde results in unequal envelope structures")
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ type AddrBook interface {
|
||||
|
||||
// AddCertifiedAddrs adds addresses from a routing.RoutingState record
|
||||
// contained in a serialized SignedEnvelope.
|
||||
AddCertifiedAddrs(envelopeBytes []byte, ttl time.Duration) error
|
||||
AddCertifiedAddrs(envelope []byte, ttl time.Duration) error
|
||||
|
||||
// SetAddr calls mgr.SetAddrs(p, addr, ttl)
|
||||
SetAddr(p peer.ID, addr ma.Multiaddr, ttl time.Duration)
|
||||
|
Loading…
Reference in New Issue
Block a user