mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
interop: slightly rephrase BuildHFSpecificMD logic
Technically, we can always buildHFSpecificMD() if contract is active, but we just optimize the build out in some cases. switch slightly obfuscates this and requires having the call in two branches. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
6b6878706a
commit
9e7fd5180a
1 changed files with 8 additions and 10 deletions
|
@ -266,18 +266,16 @@ func (c *ContractMD) BuildHFSpecificMD(activeIn *config.Hardfork) {
|
|||
}
|
||||
|
||||
for _, hf := range append([]config.Hardfork{config.HFDefault}, config.Hardforks...) {
|
||||
switch {
|
||||
case hf.Cmp(start) < 0:
|
||||
if hf.Cmp(start) < 0 {
|
||||
continue
|
||||
case hf.Cmp(start) == 0:
|
||||
c.buildHFSpecificMD(hf)
|
||||
default:
|
||||
if _, ok := c.ActiveHFs[hf]; !ok {
|
||||
// Intentionally omit HFSpecificContractMD structure copying since mdCache is read-only.
|
||||
c.mdCache[hf] = c.mdCache[hf.Prev()]
|
||||
continue
|
||||
}
|
||||
}
|
||||
_, contractHasChanges := c.ActiveHFs[hf]
|
||||
if hf.Cmp(start) == 0 || contractHasChanges {
|
||||
c.buildHFSpecificMD(hf)
|
||||
} else {
|
||||
// Optimize out MD rebuild, the contract is the same.
|
||||
// Intentionally omit HFSpecificContractMD structure copying since mdCache is read-only.
|
||||
c.mdCache[hf] = c.mdCache[hf.Prev()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue