|
|
@ -497,7 +497,9 @@ func (self *ChainManager) procFutureBlocks() { |
|
|
|
self.InsertChain(blocks) |
|
|
|
self.InsertChain(blocks) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self *ChainManager) InsertChain(chain types.Blocks) error { |
|
|
|
// InsertChain will attempt to insert the given chain in to the canonical chain or, otherwise, create a fork. It an error is returned
|
|
|
|
|
|
|
|
// it will return the index number of the failing block as well an error describing what went wrong (for possible errors see core/errors.go).
|
|
|
|
|
|
|
|
func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { |
|
|
|
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
|
|
|
|
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
queue = make([]interface{}, len(chain)) |
|
|
|
queue = make([]interface{}, len(chain)) |
|
|
@ -540,7 +542,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error { |
|
|
|
glog.V(logger.Error).Infoln(err) |
|
|
|
glog.V(logger.Error).Infoln(err) |
|
|
|
glog.V(logger.Debug).Infoln(block) |
|
|
|
glog.V(logger.Debug).Infoln(block) |
|
|
|
|
|
|
|
|
|
|
|
return err |
|
|
|
return i, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
block.Td = new(big.Int).Set(CalculateTD(block, self.GetBlock(block.ParentHash()))) |
|
|
|
block.Td = new(big.Int).Set(CalculateTD(block, self.GetBlock(block.ParentHash()))) |
|
|
@ -613,7 +615,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error { |
|
|
|
|
|
|
|
|
|
|
|
go self.eventMux.Post(queueEvent) |
|
|
|
go self.eventMux.Post(queueEvent) |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return 0, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// diff takes two blocks, an old chain and a new chain and will reconstruct the blocks and inserts them
|
|
|
|
// diff takes two blocks, an old chain and a new chain and will reconstruct the blocks and inserts them
|
|
|
|