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

Method Xmit

p2pserver/p2pserver.go:152–177  ·  view source on GitHub ↗

Xmit called by other module to broadcast msg

(message interface{})

Source from the content-addressed store, hash-verified

150
151//Xmit called by other module to broadcast msg
152func (this *P2PServer) Xmit(message interface{}) error {
153 log.Debug()
154 var msg msgtypes.Message
155 switch message.(type) {
156 case *types.Transaction:
157 log.Debug("[p2p]TX transaction message")
158 txn := message.(*types.Transaction)
159 msg = msgpack.NewTxn(txn)
160 case *msgtypes.ConsensusPayload:
161 log.Debug("[p2p]TX consensus message")
162 consensusPayload := message.(*msgtypes.ConsensusPayload)
163 msg = msgpack.NewConsensus(consensusPayload)
164 case comm.Uint256:
165 log.Debug("[p2p]TX block hash message")
166 hash := message.(comm.Uint256)
167 // construct inv message
168 invPayload := msgpack.NewInvPayload(comm.BLOCK, []comm.Uint256{hash})
169 msg = msgpack.NewInv(invPayload)
170 default:
171 log.Warnf("[p2p]Unknown Xmit message %v , type %v", message,
172 reflect.TypeOf(message))
173 return errors.New("[p2p]Unknown Xmit message type")
174 }
175 this.network.Xmit(msg)
176 return nil
177}
178
179//Send tranfer buffer to peer
180func (this *P2PServer) Send(p *peer.Peer, msg msgtypes.Message,

Callers

nothing calls this directly

Calls 3

DebugFunction · 0.92
WarnfFunction · 0.92
XmitMethod · 0.65

Tested by

no test coverage detected