aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go3
-rw-r--r--eth/block_pool.go4
-rw-r--r--eth/protocol.go12
-rw-r--r--eth/protocol_test.go2
4 files changed, 17 insertions, 4 deletions
diff --git a/eth/backend.go b/eth/backend.go
index cb00069d3..43e757435 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -137,14 +137,13 @@ func New(config *Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
- fmt.Println(nat)
eth.net = &p2p.Server{
Identity: clientId,
MaxPeers: config.MaxPeers,
Protocols: protocols,
Blacklist: eth.blacklist,
- NAT: p2p.UPNP(),
+ NAT: nat,
NoDial: !config.Dial,
}
diff --git a/eth/block_pool.go b/eth/block_pool.go
index 97ae683c1..13016c694 100644
--- a/eth/block_pool.go
+++ b/eth/block_pool.go
@@ -636,12 +636,12 @@ func (self *BlockPool) AddBlock(block *types.Block, peerId string) {
// validate block for PoW
if !self.verifyPoW(block) {
- poolLogger.Warnf("invalid pow on block [%s] by peer %s", name(hash), peerId)
+ poolLogger.Warnf("invalid pow on block [%s %v] by peer %s", name(hash), block.Number(), peerId)
self.peerError(peerId, ErrInvalidPoW, "%x", hash)
return
}
}
- poolLogger.Debugf("added block [%s] sent by peer %s", name(hash), peerId)
+ poolLogger.DebugDetailf("added block [%s] sent by peer %s", name(hash), peerId)
node.block = block
node.blockBy = peerId
diff --git a/eth/protocol.go b/eth/protocol.go
index 68c52b7ce..d7a7fa910 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -46,6 +46,7 @@ type ethProtocol struct {
// used as an argument to EthProtocol
type txPool interface {
AddTransactions([]*types.Transaction)
+ GetTransactions() types.Transactions
}
type chainManager interface {
@@ -101,6 +102,7 @@ func runEthProtocol(txPool txPool, chainManager chainManager, blockPool blockPoo
}
err = self.handleStatus()
if err == nil {
+ self.propagateTxs()
for {
err = self.handle()
if err != nil {
@@ -324,3 +326,13 @@ func (self *ethProtocol) protoErrorDisconnect(code int, format string, params ..
}
}
+
+func (self *ethProtocol) propagateTxs() {
+ transactions := self.txPool.GetTransactions()
+ iface := make([]interface{}, len(transactions))
+ for i, transaction := range transactions {
+ iface[i] = transaction
+ }
+
+ self.rw.WriteMsg(p2p.NewMsg(TxMsg, iface...))
+}
diff --git a/eth/protocol_test.go b/eth/protocol_test.go
index 224b59abd..1fe6d8f6b 100644
--- a/eth/protocol_test.go
+++ b/eth/protocol_test.go
@@ -80,6 +80,8 @@ func (self *testTxPool) AddTransactions(txs []*types.Transaction) {
}
}
+func (self *testTxPool) GetTransactions() types.Transactions { return nil }
+
func (self *testChainManager) GetBlockHashesFromHash(hash []byte, amount uint64) (hashes [][]byte) {
if self.getBlockHashes != nil {
hashes = self.getBlockHashes(hash, amount)