Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
12e8d9c4
Commit
12e8d9c4
authored
Apr 18, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: listen for mined blocks and propagate using the protocol manager
parent
ecc74d76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
17 deletions
+15
-17
backend.go
eth/backend.go
+15
-17
No files found.
eth/backend.go
View file @
12e8d9c4
...
@@ -136,11 +136,11 @@ type Ethereum struct {
...
@@ -136,11 +136,11 @@ type Ethereum struct {
protocolManager
*
ProtocolManager
protocolManager
*
ProtocolManager
downloader
*
downloader
.
Downloader
downloader
*
downloader
.
Downloader
net
*
p2p
.
Server
net
*
p2p
.
Server
eventMux
*
event
.
TypeMux
eventMux
*
event
.
TypeMux
txSub
event
.
Subscription
txSub
event
.
Subscription
//b
lockSub event.Subscription
minedB
lockSub
event
.
Subscription
miner
*
miner
.
Miner
miner
*
miner
.
Miner
// logger logger.LogSystem
// logger logger.LogSystem
...
@@ -387,8 +387,8 @@ func (s *Ethereum) Start() error {
...
@@ -387,8 +387,8 @@ func (s *Ethereum) Start() error {
go
s
.
txBroadcastLoop
()
go
s
.
txBroadcastLoop
()
// broadcast mined blocks
// broadcast mined blocks
//s.blockSub = s.eventMux.Subscribe(core.ChainHead
Event{})
s
.
minedBlockSub
=
s
.
eventMux
.
Subscribe
(
core
.
NewMinedBlock
Event
{})
go
s
.
block
BroadcastLoop
()
go
s
.
mined
BroadcastLoop
()
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Server started"
)
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Server started"
)
return
nil
return
nil
...
@@ -419,8 +419,8 @@ func (s *Ethereum) Stop() {
...
@@ -419,8 +419,8 @@ func (s *Ethereum) Stop() {
defer
s
.
stateDb
.
Close
()
defer
s
.
stateDb
.
Close
()
defer
s
.
extraDb
.
Close
()
defer
s
.
extraDb
.
Close
()
s
.
txSub
.
Unsubscribe
()
// quits txBroadcastLoop
s
.
txSub
.
Unsubscribe
()
// quits txBroadcastLoop
//s.b
lockSub.Unsubscribe() // quits blockBroadcastLoop
s
.
minedB
lockSub
.
Unsubscribe
()
// quits blockBroadcastLoop
s
.
txPool
.
Stop
()
s
.
txPool
.
Stop
()
s
.
eventMux
.
Stop
()
s
.
eventMux
.
Stop
()
...
@@ -462,16 +462,14 @@ func (self *Ethereum) syncAccounts(tx *types.Transaction) {
...
@@ -462,16 +462,14 @@ func (self *Ethereum) syncAccounts(tx *types.Transaction) {
}
}
}
}
func
(
self
*
Ethereum
)
block
BroadcastLoop
()
{
func
(
self
*
Ethereum
)
mined
BroadcastLoop
()
{
// automatically stops if unsubscribe
// automatically stops if unsubscribe
/*
for
obj
:=
range
self
.
minedBlockSub
.
Chan
()
{
for obj := range self.blockSub.Chan() {
switch
ev
:=
obj
.
(
type
)
{
switch ev := obj.(type) {
case
core
.
NewMinedBlockEvent
:
case core.ChainHeadEvent:
self
.
protocolManager
.
BroadcastBlock
(
ev
.
Block
)
self.net.BroadcastLimited("eth", NewBlockMsg, math.Sqrt, []interface{}{ev.Block, ev.Block.Td})
}
}
}
*/
}
}
}
func
saveProtocolVersion
(
db
common
.
Database
,
protov
int
)
{
func
saveProtocolVersion
(
db
common
.
Database
,
protov
int
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment