| 838 | } |
| 839 | |
| 840 | func (bc *BlockChain) procFutureBlocks() { |
| 841 | blocks := make([]*types.Block, 0, bc.futureBlocks.Len()) |
| 842 | for _, hash := range bc.futureBlocks.Keys() { |
| 843 | if block, exist := bc.futureBlocks.Peek(hash); exist { |
| 844 | blocks = append(blocks, block.(*types.Block)) |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | if len(blocks) > 0 { |
| 849 | types.BlockBy(types.Number).Sort(blocks) |
| 850 | |
| 851 | // Insert one by one as chain insertion needs contiguous ancestry between blocks |
| 852 | for i := range blocks { |
| 853 | _, err := bc.InsertChain(blocks[i : i+1]) |
| 854 | bc.ErrChan <- err |
| 855 | log.Debug("err of future insert, go to bc.ErrChan", "err", err) |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | func (bc *BlockChain) procUnknownAncestors() { |
| 861 | blocks := make([]*types.Block, 0, bc.unknownAncestors.Len()) |