File tree Expand file tree Collapse file tree 1 file changed +14
-25
lines changed
Expand file tree Collapse file tree 1 file changed +14
-25
lines changed Original file line number Diff line number Diff line change @@ -194,34 +194,23 @@ func (self *worker) setExtra(extra []byte) {
194194 self .extra = extra
195195}
196196
197- func (self * worker ) pending () (* types.Block , * state.StateDB ) {
198- self .currentMu .Lock ()
199- defer self .currentMu .Unlock ()
200-
201- if atomic .LoadInt32 (& self .mining ) == 0 {
202- return types .NewBlock (
203- self .current .header ,
204- self .current .txs ,
205- nil ,
206- self .current .receipts ,
207- ), self .current .state .Copy ()
197+ // pending returns the pending state and corresponding block. The returned
198+ // values can be nil in case the pending block is not initialized.
199+ func (w * worker ) pending () (* types.Block , * state.StateDB ) {
200+ w .snapshotMu .RLock ()
201+ defer w .snapshotMu .RUnlock ()
202+ if w .snapshotState == nil {
203+ return nil , nil
208204 }
209- return self . current . Block , self . current . state .Copy ()
205+ return w . snapshotBlock , w . snapshotState .Copy ()
210206}
211207
212- func (self * worker ) pendingBlock () * types.Block {
213- self .currentMu .Lock ()
214- defer self .currentMu .Unlock ()
215-
216- if atomic .LoadInt32 (& self .mining ) == 0 {
217- return types .NewBlock (
218- self .current .header ,
219- self .current .txs ,
220- nil ,
221- self .current .receipts ,
222- )
223- }
224- return self .current .Block
208+ // pendingBlock returns pending block. The returned block can be nil in case the
209+ // pending block is not initialized.
210+ func (w * worker ) pendingBlock () * types.Block {
211+ w .snapshotMu .RLock ()
212+ defer w .snapshotMu .RUnlock ()
213+ return w .snapshotBlock
225214}
226215
227216// pendingBlockAndReceipts returns pending block and corresponding receipts.
You can’t perform that action at this time.
0 commit comments