-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
96 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package facade | ||
|
||
type SimulatorHandler interface { | ||
GenerateBlocks(numOfBlocks int) error | ||
IsInterfaceNil() bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package facade | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/multiversx/mx-chain-core-go/core/check" | ||
) | ||
|
||
type simulatorFacade struct { | ||
simulator SimulatorHandler | ||
} | ||
|
||
func NewSimulatorFacade(simulator SimulatorHandler) (*simulatorFacade, error) { | ||
if check.IfNil(simulator) { | ||
return nil, errors.New("nil simulator handler ") | ||
} | ||
|
||
return &simulatorFacade{ | ||
simulator: simulator, | ||
}, nil | ||
} | ||
|
||
func (sf *simulatorFacade) GenerateBlocks(numOfBlocks int) error { | ||
if numOfBlocks <= 0 { | ||
return errors.New("num of blocks must be greater than zero") | ||
} | ||
return sf.simulator.GenerateBlocks(numOfBlocks) | ||
} | ||
|
||
func (sf *simulatorFacade) IsInterfaceNil() bool { | ||
return sf == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters