From cc436c4b28c95f825499d67c92a18de5d27e90c2 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 18 Apr 2015 02:21:07 +0200 Subject: eth: additional cleanups to the subprotocol, improved block propagation * Improved block propagation by sending blocks only to peers to which, as far as we know, the peer does not know about. * Made sub protocol its own manager * SubProtocol now contains the p2p.Protocol which is used instead of a function-returning-protocol thing. --- eth/peer.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'eth/peer.go') diff --git a/eth/peer.go b/eth/peer.go index db7fea7a7..8cedbd85a 100644 --- a/eth/peer.go +++ b/eth/peer.go @@ -78,6 +78,12 @@ func (p *peer) sendBlocks(blocks []*types.Block) error { return p2p.Send(p.rw, BlocksMsg, blocks) } +func (p *peer) sendNewBlock(block *types.Block) error { + p.blockHashes.Add(block.Hash()) + + return p2p.Send(p.rw, NewBlockMsg, []interface{}{block, block.Td}) +} + func (p *peer) requestHashes(from common.Hash) error { p.Debugf("fetching hashes (%d) %x...\n", maxHashes, from[0:4]) return p2p.Send(p.rw, GetBlockHashesMsg, getBlockHashesMsgData{from, maxHashes}) -- cgit