MCPcopy Create free account
hub / github.com/DNAProject/DNA / Deserialization

Method Deserialization

p2pserver/message/types/address.go:54–82  ·  view source on GitHub ↗
(source *common.ZeroCopySource)

Source from the content-addressed store, hash-verified

52}
53
54func (this *Addr) Deserialization(source *common.ZeroCopySource) error {
55 count, eof := source.NextUint64()
56 if eof {
57 return io.ErrUnexpectedEOF
58 }
59
60 for i := 0; i < int(count); i++ {
61 var addr comm.PeerAddr
62 addr.Time, eof = source.NextInt64()
63 addr.Services, eof = source.NextUint64()
64 buf, _ := source.NextBytes(uint64(len(addr.IpAddr[:])))
65 copy(addr.IpAddr[:], buf)
66 addr.Port, eof = source.NextUint16()
67 addr.ConsensusPort, eof = source.NextUint16()
68 addr.ID, eof = source.NextUint64()
69 if eof {
70 return io.ErrUnexpectedEOF
71 }
72
73 this.NodeAddrs = append(this.NodeAddrs, addr)
74 }
75
76 if count > comm.MAX_ADDR_NODE_CNT {
77 count = comm.MAX_ADDR_NODE_CNT
78 }
79 this.NodeAddrs = this.NodeAddrs[:count]
80
81 return nil
82}

Callers

nothing calls this directly

Calls 4

NextUint64Method · 0.80
NextInt64Method · 0.80
NextUint16Method · 0.80
NextBytesMethod · 0.45

Tested by

no test coverage detected