File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -1633,6 +1633,16 @@ func (b *Blockchain) SetClock(clock Clock) {
16331633 b .pendingBlock .SetClock (clock )
16341634}
16351635
1636+ // NewScriptEnvironment returns an environment.Environment by
1637+ // using as a storage snapshot the blockchain's ledger state.
1638+ // Useful for tools that use the emulator's blockchain as a library.
1639+ func (b * Blockchain ) NewScriptEnvironment () environment.Environment {
1640+ return environment .NewScriptEnvironmentFromStorageSnapshot (
1641+ b .vmCtx .EnvironmentParams ,
1642+ b .pendingBlock .ledgerState .NewChild (),
1643+ )
1644+ }
1645+
16361646func (b * Blockchain ) GetSourceFile (location common.Location ) string {
16371647
16381648 value , exists := b .sourceFileMap [location ]
@@ -1644,12 +1654,8 @@ func (b *Blockchain) GetSourceFile(location common.Location) string {
16441654 if ! isAddressLocation {
16451655 return location .ID ()
16461656 }
1647- view := b .pendingBlock .ledgerState .NewChild ()
1648-
1649- env := environment .NewScriptEnvironmentFromStorageSnapshot (
1650- b .vmCtx .EnvironmentParams ,
1651- view )
16521657
1658+ env := b .NewScriptEnvironment ()
16531659 r := b .vmCtx .Borrow (env )
16541660 defer b .vmCtx .Return (r )
16551661
You can’t perform that action at this time.
0 commit comments