diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-18 08:21:07 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-18 08:21:07 +0800 |
commit | cc436c4b28c95f825499d67c92a18de5d27e90c2 (patch) | |
tree | 1b98f50aff0d071b943951c9244bab2fb1451077 /eth/peer.go | |
parent | c2f410214c99ee3636cfb670e84e5f05d179a1ef (diff) | |
download | go-tangerine-cc436c4b28c95f825499d67c92a18de5d27e90c2.tar.gz go-tangerine-cc436c4b28c95f825499d67c92a18de5d27e90c2.tar.zst go-tangerine-cc436c4b28c95f825499d67c92a18de5d27e90c2.zip |
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.
Diffstat (limited to 'eth/peer.go')
-rw-r--r-- | eth/peer.go | 6 |
1 files changed, 6 insertions, 0 deletions
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}) |