mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
core: remove (*block.Block) checks for topBlock
If it's non-nil, it has *block.Block inside. If it doesn't --- tell everyone about it with a nice panic message.
This commit is contained in:
parent
33ea179f6e
commit
6bffa811d4
1 changed files with 6 additions and 5 deletions
|
@ -901,7 +901,8 @@ func (bc *Blockchain) GetStorageItems(id int32) (map[string]*state.StorageItem,
|
||||||
func (bc *Blockchain) GetBlock(hash util.Uint256) (*block.Block, error) {
|
func (bc *Blockchain) GetBlock(hash util.Uint256) (*block.Block, error) {
|
||||||
topBlock := bc.topBlock.Load()
|
topBlock := bc.topBlock.Load()
|
||||||
if topBlock != nil {
|
if topBlock != nil {
|
||||||
if tb, ok := topBlock.(*block.Block); ok && tb.Hash().Equals(hash) {
|
tb := topBlock.(*block.Block)
|
||||||
|
if tb.Hash().Equals(hash) {
|
||||||
return tb, nil
|
return tb, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -924,7 +925,8 @@ func (bc *Blockchain) GetBlock(hash util.Uint256) (*block.Block, error) {
|
||||||
func (bc *Blockchain) GetHeader(hash util.Uint256) (*block.Header, error) {
|
func (bc *Blockchain) GetHeader(hash util.Uint256) (*block.Header, error) {
|
||||||
topBlock := bc.topBlock.Load()
|
topBlock := bc.topBlock.Load()
|
||||||
if topBlock != nil {
|
if topBlock != nil {
|
||||||
if tb, ok := topBlock.(*block.Block); ok && tb.Hash().Equals(hash) {
|
tb := topBlock.(*block.Block)
|
||||||
|
if tb.Hash().Equals(hash) {
|
||||||
return tb.Header(), nil
|
return tb.Header(), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -954,9 +956,8 @@ func (bc *Blockchain) HasBlock(hash util.Uint256) bool {
|
||||||
func (bc *Blockchain) CurrentBlockHash() util.Uint256 {
|
func (bc *Blockchain) CurrentBlockHash() util.Uint256 {
|
||||||
topBlock := bc.topBlock.Load()
|
topBlock := bc.topBlock.Load()
|
||||||
if topBlock != nil {
|
if topBlock != nil {
|
||||||
if tb, ok := topBlock.(*block.Block); ok {
|
tb := topBlock.(*block.Block)
|
||||||
return tb.Hash()
|
return tb.Hash()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return bc.GetHeaderHash(int(bc.BlockHeight()))
|
return bc.GetHeaderHash(int(bc.BlockHeight()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue