diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-07-08 23:53:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-08 23:53:47 +0800 |
commit | 983f92368bdd79c65082ac2c98cbc0d58b28b22b (patch) | |
tree | cc0decc510e52366f0f44288667b6b9bfdbbe8f6 /eth/backend.go | |
parent | cc0f0e27a673fa7c0d14ab36ed0847314bdb3e2c (diff) | |
download | go-tangerine-983f92368bdd79c65082ac2c98cbc0d58b28b22b.tar go-tangerine-983f92368bdd79c65082ac2c98cbc0d58b28b22b.tar.gz go-tangerine-983f92368bdd79c65082ac2c98cbc0d58b28b22b.tar.bz2 go-tangerine-983f92368bdd79c65082ac2c98cbc0d58b28b22b.tar.lz go-tangerine-983f92368bdd79c65082ac2c98cbc0d58b28b22b.tar.xz go-tangerine-983f92368bdd79c65082ac2c98cbc0d58b28b22b.tar.zst go-tangerine-983f92368bdd79c65082ac2c98cbc0d58b28b22b.zip |
core/forkid: implement the forkid EIP, announce via ENR (#19738)
* eth: chain config (genesis + fork) ENR entry
* core/forkid, eth: protocol independent fork ID, update to CRC32 spec
* core/forkid, eth: make forkid a struct, next uint64, enr struct, RLP
* core/forkid: change forkhash rlp encoding from int to [4]byte
* eth: fixup eth entry a bit and update it every block
* eth: fix lint
* eth: fix crash in ethclient tests
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/eth/backend.go b/eth/backend.go index a3275caca..dc4ff8ade 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -47,6 +47,7 @@ import ( "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/enr" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -66,7 +67,9 @@ type Ethereum struct { config *Config // Channel for shutting down the service - shutdownChan chan bool // Channel for shutting down the Ethereum + shutdownChan chan bool + + server *p2p.Server // Handlers txPool *core.TxPool @@ -496,7 +499,7 @@ func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux } func (s *Ethereum) Engine() consensus.Engine { return s.engine } func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb } func (s *Ethereum) IsListening() bool { return true } // Always listening -func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) } +func (s *Ethereum) EthVersion() int { return int(ProtocolVersions[0]) } func (s *Ethereum) NetVersion() uint64 { return s.networkID } func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader } func (s *Ethereum) Synced() bool { return atomic.LoadUint32(&s.protocolManager.acceptTxs) == 1 } @@ -505,15 +508,22 @@ func (s *Ethereum) ArchiveMode() bool { return s.config.NoPruni // Protocols implements node.Service, returning all the currently configured // network protocols to start. func (s *Ethereum) Protocols() []p2p.Protocol { - if s.lesServer == nil { - return s.protocolManager.SubProtocols + protos := make([]p2p.Protocol, len(ProtocolVersions)) + for i, vsn := range ProtocolVersions { + protos[i] = s.protocolManager.makeProtocol(vsn) + protos[i].Attributes = []enr.Entry{s.currentEthEntry()} + } + if s.lesServer != nil { + protos = append(protos, s.lesServer.Protocols()...) } - return append(s.protocolManager.SubProtocols, s.lesServer.Protocols()...) + return protos } // Start implements node.Service, starting all internal goroutines needed by the // Ethereum protocol implementation. func (s *Ethereum) Start(srvr *p2p.Server) error { + s.startEthEntryUpdate(srvr.LocalNode()) + // Start the bloom bits servicing goroutines s.startBloomHandlers(params.BloomBitsBlocks) |