diff options
Diffstat (limited to 'vm/context.go')
-rw-r--r-- | vm/context.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/vm/context.go b/vm/context.go index d14df1aa7..b48f1a657 100644 --- a/vm/context.go +++ b/vm/context.go @@ -61,6 +61,13 @@ func (c *Context) GetRangeValue(x, size uint64) []byte { return ethutil.LeftPadBytes(c.Code[x:y], int(size)) } +func (c *Context) GetCode(x, size uint64) []byte { + x = uint64(math.Min(float64(x), float64(len(c.Code)))) + y := uint64(math.Min(float64(x+size), float64(len(c.Code)))) + + return ethutil.RightPadBytes(c.Code[x:y], int(size)) +} + func (c *Context) Return(ret []byte) []byte { // Return the remaining gas to the caller c.caller.ReturnGas(c.Gas, c.Price) |