@@ -131,16 +131,22 @@ func (miner *Miner) update() {
131
131
shouldStart = true
132
132
log .Info ("Mining aborted due to sync" )
133
133
}
134
+ miner .worker .syncing .Store (true )
135
+
134
136
case downloader.FailedEvent :
135
137
canStart = true
136
138
if shouldStart {
137
139
miner .worker .start ()
138
140
}
141
+ miner .worker .syncing .Store (false )
142
+
139
143
case downloader.DoneEvent :
140
144
canStart = true
141
145
if shouldStart {
142
146
miner .worker .start ()
143
147
}
148
+ miner .worker .syncing .Store (false )
149
+
144
150
// Stop reacting to downloader events
145
151
events .Unsubscribe ()
146
152
}
@@ -196,12 +202,14 @@ func (miner *Miner) SetRecommitInterval(interval time.Duration) {
196
202
miner .worker .setRecommitInterval (interval )
197
203
}
198
204
199
- // Pending returns the currently pending block and associated state.
205
+ // Pending returns the currently pending block and associated state. The returned
206
+ // values can be nil in case the pending block is not initialized
200
207
func (miner * Miner ) Pending () (* types.Block , * state.StateDB ) {
201
208
return miner .worker .pending ()
202
209
}
203
210
204
- // PendingBlock returns the currently pending block.
211
+ // PendingBlock returns the currently pending block. The returned block can be
212
+ // nil in case the pending block is not initialized.
205
213
//
206
214
// Note, to access both the pending block and the pending state
207
215
// simultaneously, please use Pending(), as the pending state can
@@ -211,6 +219,7 @@ func (miner *Miner) PendingBlock() *types.Block {
211
219
}
212
220
213
221
// PendingBlockAndReceipts returns the currently pending block and corresponding receipts.
222
+ // The returned values can be nil in case the pending block is not initialized.
214
223
func (miner * Miner ) PendingBlockAndReceipts () (* types.Block , types.Receipts ) {
215
224
return miner .worker .pendingBlockAndReceipts ()
216
225
}
@@ -225,23 +234,6 @@ func (miner *Miner) SetGasCeil(ceil uint64) {
225
234
miner .worker .setGasCeil (ceil )
226
235
}
227
236
228
- // EnablePreseal turns on the preseal mining feature. It's enabled by default.
229
- // Note this function shouldn't be exposed to API, it's unnecessary for users
230
- // (miners) to actually know the underlying detail. It's only for outside project
231
- // which uses this library.
232
- func (miner * Miner ) EnablePreseal () {
233
- miner .worker .enablePreseal ()
234
- }
235
-
236
- // DisablePreseal turns off the preseal mining feature. It's necessary for some
237
- // fake consensus engine which can seal blocks instantaneously.
238
- // Note this function shouldn't be exposed to API, it's unnecessary for users
239
- // (miners) to actually know the underlying detail. It's only for outside project
240
- // which uses this library.
241
- func (miner * Miner ) DisablePreseal () {
242
- miner .worker .disablePreseal ()
243
- }
244
-
245
237
// SubscribePendingLogs starts delivering logs from pending transactions
246
238
// to the given channel.
247
239
func (miner * Miner ) SubscribePendingLogs (ch chan <- []* types.Log ) event.Subscription {
0 commit comments