mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2025-03-22 12:20:07 +08:00
go fmt
This commit is contained in:
parent
2ebfd9d4f2
commit
c016eb5a80
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user