Skip to content

Commit

Permalink
chore: fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Mar 14, 2023
1 parent f891c0a commit a37bbef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dot/state/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ func (bs *BlockState) closestAncestorWithInstance(blockHash common.Hash) (instan
// the first ancestor will have the highest number which means it is
// the closest ancestor with an instance
if isDescendant {
return bs.bt.RuntimesMappingGet(header.Hash()), nil
return bs.bt.GetBlockRuntimeOrFail(header.Hash())
}
}

Expand Down
18 changes: 10 additions & 8 deletions lib/blocktree/blocktree.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ func (bt *BlockTree) StoreRuntime(hash common.Hash, instance Runtime) {
bt.runtimes.set(hash, instance)
}

// GetBlockRuntime returns block runtime for corresponding block hash.
// GetBlockRuntime returns block runtime for corresponding block hash, if there is no instance for
// the given block hash it will lookup an instance of an ancestor and returns it.
func (bt *BlockTree) GetBlockRuntime(hash common.Hash) (Runtime, error) {
// if the current node contains a runtime entry in the runtime mapping
// then we early return the instance, otherwise we will lookup for the
Expand Down Expand Up @@ -562,17 +563,18 @@ func (bt *BlockTree) GetBlockRuntime(hash common.Hash) (Runtime, error) {
return nil, ErrRuntimeNotFound
}

// GetInMemoryRuntimesBlockHashes returns all the runtimes mapping keys
func (bt *BlockTree) GetInMemoryRuntimesBlockHashes() []common.Hash {
return bt.runtimes.hashes()
}

func (bt *BlockTree) RuntimesMappingGet(hash common.Hash) (instance Runtime) {
bt.runtimesLock.RLock()
defer bt.runtimesLock.RUnlock()

if bt.runtimes == nil {
return nil
// GetBlockRuntime returns block runtime for corresponding block hash. if there is no instance
// fot the given block hash it returns ErrRuntimeNotFound
func (bt *BlockTree) GetBlockRuntimeOrFail(hash common.Hash) (instance Runtime, err error) {
instance = bt.runtimes.get(hash)
if instance == nil {
return nil, ErrRuntimeNotFound
}

return bt.runtimes.get(hash)
return instance, nil
}

0 comments on commit a37bbef

Please sign in to comment.