Coverage Summary for Class: Op (org.ethereum.vm.trace)
Class |
Class, %
|
Method, %
|
Line, %
|
Op |
0%
(0/1)
|
0%
(0/11)
|
0%
(0/19)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 * (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>)
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package org.ethereum.vm.trace;
21
22 import org.ethereum.util.ByteUtil;
23 import org.ethereum.vm.OpCode;
24 import org.ethereum.vm.program.Memory;
25 import org.ethereum.vm.program.Stack;
26
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32 public class Op {
33
34 private OpCode op;
35 private int depth;
36 private int pc;
37 private long gas;
38 private long gasCost;
39
40 // Note that "memory" and "stack" are included in JSON serialization (debug_traceTransaction)
41 // so we remove them from LGTM warnings.
42 private List<String> memory = new ArrayList<>(); // lgtm [java/unused-container]
43 private List<String> stack = new ArrayList<>(); // lgtm [java/unused-container]
44 private Map<String, String> storage = new HashMap<>();
45
46 public OpCode getOp() {
47 return op;
48 }
49
50 public void setOp(OpCode op) {
51 this.op = op;
52 }
53
54 public void setDepth(int depth) {
55 this.depth = depth;
56 }
57
58 public void setPc(int pc) {
59 this.pc = pc;
60 }
61
62 public long getGas() {
63 return gas;
64 }
65
66 public void setGas(long gas) {
67 this.gas = gas;
68 }
69
70 public void setGasCost(long gasCost) { this.gasCost = gasCost; }
71
72 public void setMemory(Memory memory) {
73 int size = memory.size();
74
75 for (int k = 0; k < size; k += 32) {
76 byte[] bytes = memory.read(k, Math.min(32, size - k));
77 this.memory.add(ByteUtil.toHexString(bytes));
78 }
79 }
80
81 public void setStorage(Map<String, String> storage) {
82 this.storage = storage;
83 }
84
85 public void setStack(Stack stack) {
86 int size = stack.size();
87
88 for (int k = 0; k < size; k++) {
89 this.stack.add(ByteUtil.toHexString(stack.get(k).getData()));
90 }
91 }
92 }