Fix misspelling in HelloMessage

This commit is contained in:
Brian Hoffman 2020-08-04 11:33:29 -04:00
parent bd6a80505b
commit 0bb4c20e02
2 changed files with 12 additions and 12 deletions

View File

@ -172,13 +172,13 @@ func (t *LatencyMessage) MarshalCBOR(w io.Writer) error {
scratch := make([]byte, 9) scratch := make([]byte, 9)
// t.TArrial (int64) (int64) // t.TArrival (int64) (int64)
if t.TArrial >= 0 { if t.TArrival >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.TArrial)); err != nil { if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.TArrival)); err != nil {
return err return err
} }
} else { } else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.TArrial-1)); err != nil { if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.TArrival-1)); err != nil {
return err return err
} }
} }
@ -212,7 +212,7 @@ func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("cbor input had wrong number of fields") return fmt.Errorf("cbor input had wrong number of fields")
} }
// t.TArrial (int64) (int64) // t.TArrival (int64) (int64)
{ {
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
var extraI int64 var extraI int64
@ -235,7 +235,7 @@ func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("wrong type for int64 field: %d", maj) return fmt.Errorf("wrong type for int64 field: %d", maj)
} }
t.TArrial = int64(extraI) t.TArrival = int64(extraI)
} }
// t.TSent (int64) (int64) // t.TSent (int64) (int64)
{ {

View File

@ -32,8 +32,8 @@ type HelloMessage struct {
GenesisHash cid.Cid GenesisHash cid.Cid
} }
type LatencyMessage struct { type LatencyMessage struct {
TArrial int64 TArrival int64
TSent int64 TSent int64
} }
type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error) type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)
@ -84,8 +84,8 @@ func (hs *Service) HandleStream(s inet.Stream) {
sent := time.Now() sent := time.Now()
msg := &LatencyMessage{ msg := &LatencyMessage{
TArrial: arrived.UnixNano(), TArrival: arrived.UnixNano(),
TSent: sent.UnixNano(), TSent: sent.UnixNano(),
} }
if err := cborutil.WriteCborRPC(s, msg); err != nil { if err := cborutil.WriteCborRPC(s, msg); err != nil {
log.Debugf("error while responding to latency: %v", err) log.Debugf("error while responding to latency: %v", err)
@ -169,8 +169,8 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
} }
if err == nil { if err == nil {
if lmsg.TArrial != 0 && lmsg.TSent != 0 { if lmsg.TArrival != 0 && lmsg.TSent != 0 {
t1 := time.Unix(0, lmsg.TArrial) t1 := time.Unix(0, lmsg.TArrival)
t2 := time.Unix(0, lmsg.TSent) t2 := time.Unix(0, lmsg.TSent)
offset := t0.Sub(t1) + t3.Sub(t2) offset := t0.Sub(t1) + t3.Sub(t2)
offset /= 2 offset /= 2