File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,9 @@ func (self *worker) pendingBlock() *types.Block {
125
125
}
126
126
127
127
func (self * worker ) start () {
128
+ self .mu .Lock ()
129
+ defer self .mu .Unlock ()
130
+
128
131
// spin up agents
129
132
for _ , agent := range self .agents {
130
133
agent .Start ()
@@ -134,6 +137,9 @@ func (self *worker) start() {
134
137
}
135
138
136
139
func (self * worker ) stop () {
140
+ self .mu .Lock ()
141
+ defer self .mu .Unlock ()
142
+
137
143
if atomic .LoadInt32 (& self .mining ) == 1 {
138
144
// stop all agents
139
145
for _ , agent := range self .agents {
@@ -146,6 +152,9 @@ func (self *worker) stop() {
146
152
}
147
153
148
154
func (self * worker ) register (agent Agent ) {
155
+ self .mu .Lock ()
156
+ defer self .mu .Unlock ()
157
+
149
158
self .agents = append (self .agents , agent )
150
159
agent .SetReturnCh (self .recv )
151
160
}
You can’t perform that action at this time.
0 commit comments