@@ -129,37 +129,25 @@ func (p *peer) MarkTransaction(hash common.Hash) {
129129// SendTransactions sends transactions to the peer and includes the hashes
130130// in its transaction hash set for future reference.
131131func (p * peer ) SendTransactions (txs types.Transactions ) error {
132- propTxnOutPacketsMeter .Mark (1 )
133132 for _ , tx := range txs {
134- propTxnOutTrafficMeter .Mark (tx .Size ().Int64 ())
135133 p .knownTxs .Add (tx .Hash ())
136134 }
137135 return p2p .Send (p .rw , TxMsg , txs )
138136}
139137
140138// SendBlockHashes sends a batch of known hashes to the remote peer.
141139func (p * peer ) SendBlockHashes (hashes []common.Hash ) error {
142- reqHashOutPacketsMeter .Mark (1 )
143- reqHashOutTrafficMeter .Mark (int64 (32 * len (hashes )))
144-
145140 return p2p .Send (p .rw , BlockHashesMsg , hashes )
146141}
147142
148143// SendBlocks sends a batch of blocks to the remote peer.
149144func (p * peer ) SendBlocks (blocks []* types.Block ) error {
150- reqBlockOutPacketsMeter .Mark (1 )
151- for _ , block := range blocks {
152- reqBlockOutTrafficMeter .Mark (block .Size ().Int64 ())
153- }
154145 return p2p .Send (p .rw , BlocksMsg , blocks )
155146}
156147
157148// SendNewBlockHashes announces the availability of a number of blocks through
158149// a hash notification.
159150func (p * peer ) SendNewBlockHashes (hashes []common.Hash ) error {
160- propHashOutPacketsMeter .Mark (1 )
161- propHashOutTrafficMeter .Mark (int64 (32 * len (hashes )))
162-
163151 for _ , hash := range hashes {
164152 p .knownBlocks .Add (hash )
165153 }
@@ -168,33 +156,55 @@ func (p *peer) SendNewBlockHashes(hashes []common.Hash) error {
168156
169157// SendNewBlock propagates an entire block to a remote peer.
170158func (p * peer ) SendNewBlock (block * types.Block , td * big.Int ) error {
171- propBlockOutPacketsMeter .Mark (1 )
172- propBlockOutTrafficMeter .Mark (block .Size ().Int64 ())
173-
174159 p .knownBlocks .Add (block .Hash ())
175160 return p2p .Send (p .rw , NewBlockMsg , []interface {}{block , td })
176161}
177162
163+ // SendBlockHeaders sends a batch of block headers to the remote peer.
164+ func (p * peer ) SendBlockHeaders (headers []* types.Header ) error {
165+ return p2p .Send (p .rw , BlockHeadersMsg , headers )
166+ }
167+
168+ // SendNodeData sends a batch of arbitrary internal data, corresponding to the
169+ // hashes requested.
170+ func (p * peer ) SendNodeData (data [][]byte ) error {
171+ return p2p .Send (p .rw , NodeDataMsg , data )
172+ }
173+
178174// RequestHashes fetches a batch of hashes from a peer, starting at from, going
179175// towards the genesis block.
180176func (p * peer ) RequestHashes (from common.Hash ) error {
181- glog .V (logger .Debug ).Infof ("Peer [%s] fetching hashes (%d) from %x...\n " , p . id , downloader .MaxHashFetch , from [:4 ])
177+ glog .V (logger .Debug ).Infof ("%v fetching hashes (%d) from %x...\n " , p , downloader .MaxHashFetch , from [:4 ])
182178 return p2p .Send (p .rw , GetBlockHashesMsg , getBlockHashesData {from , uint64 (downloader .MaxHashFetch )})
183179}
184180
185- // RequestHashesFromNumber fetches a batch of hashes from a peer, starting at the
186- // requested block number, going upwards towards the genesis block.
181+ // RequestHashesFromNumber fetches a batch of hashes from a peer, starting at
182+ // the requested block number, going upwards towards the genesis block.
187183func (p * peer ) RequestHashesFromNumber (from uint64 , count int ) error {
188- glog .V (logger .Debug ).Infof ("Peer [%s] fetching hashes (%d) from #%d...\n " , p . id , count , from )
184+ glog .V (logger .Debug ).Infof ("%v fetching hashes (%d) from #%d...\n " , p , count , from )
189185 return p2p .Send (p .rw , GetBlockHashesFromNumberMsg , getBlockHashesFromNumberData {from , uint64 (count )})
190186}
191187
192188// RequestBlocks fetches a batch of blocks corresponding to the specified hashes.
193189func (p * peer ) RequestBlocks (hashes []common.Hash ) error {
194- glog .V (logger .Debug ).Infof ("[%s] fetching %v blocks\n " , p . id , len (hashes ))
190+ glog .V (logger .Debug ).Infof ("%v fetching %v blocks\n " , p , len (hashes ))
195191 return p2p .Send (p .rw , GetBlocksMsg , hashes )
196192}
197193
194+ // RequestHeaders fetches a batch of blocks' headers corresponding to the
195+ // specified hashes.
196+ func (p * peer ) RequestHeaders (hashes []common.Hash ) error {
197+ glog .V (logger .Debug ).Infof ("%v fetching %v headers\n " , p , len (hashes ))
198+ return p2p .Send (p .rw , GetBlockHeadersMsg , hashes )
199+ }
200+
201+ // RequestNodeData fetches a batch of arbitrary data from a node's known state
202+ // data, corresponding to the specified hashes.
203+ func (p * peer ) RequestNodeData (hashes []common.Hash ) error {
204+ glog .V (logger .Debug ).Infof ("%v fetching %v state data\n " , p , len (hashes ))
205+ return p2p .Send (p .rw , GetNodeDataMsg , hashes )
206+ }
207+
198208// Handshake executes the eth protocol handshake, negotiating version number,
199209// network IDs, difficulties, head and genesis blocks.
200210func (p * peer ) Handshake (td * big.Int , head common.Hash , genesis common.Hash ) error {
0 commit comments