mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-26 05:17:19 +00:00
Merge branch 'develop' into downloader-proto
This commit is contained in:
commit
d34e4dc5ac
@ -366,6 +366,12 @@ func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block {
|
|||||||
self.mu.RLock()
|
self.mu.RLock()
|
||||||
defer self.mu.RUnlock()
|
defer self.mu.RUnlock()
|
||||||
|
|
||||||
|
return self.getBlockByNumber(num)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// non blocking version
|
||||||
|
func (self *ChainManager) getBlockByNumber(num uint64) *types.Block {
|
||||||
key, _ := self.blockDb.Get(append(blockNumPre, big.NewInt(int64(num)).Bytes()...))
|
key, _ := self.blockDb.Get(append(blockNumPre, big.NewInt(int64(num)).Bytes()...))
|
||||||
if len(key) == 0 {
|
if len(key) == 0 {
|
||||||
return nil
|
return nil
|
||||||
@ -507,7 +513,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
|
|||||||
glog.Infof("Split detected. New head #%v (%x) TD=%v, was #%v (%x) TD=%v\n", block.Header().Number, hash[:4], td, cblock.Header().Number, chash[:4], self.td)
|
glog.Infof("Split detected. New head #%v (%x) TD=%v, was #%v (%x) TD=%v\n", block.Header().Number, hash[:4], td, cblock.Header().Number, chash[:4], self.td)
|
||||||
}
|
}
|
||||||
// during split we merge two different chains and create the new canonical chain
|
// during split we merge two different chains and create the new canonical chain
|
||||||
self.merge(cblock, block)
|
self.merge(self.getBlockByNumber(block.NumberU64()), block)
|
||||||
|
|
||||||
queue[i] = ChainSplitEvent{block, logs}
|
queue[i] = ChainSplitEvent{block, logs}
|
||||||
queueEvent.splitCount++
|
queueEvent.splitCount++
|
||||||
|
Loading…
Reference in New Issue
Block a user