Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding word_data size constant #3258

Merged
merged 5 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions common/src/main/java/org/tron/common/runtime/vm/DataWord.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class DataWord implements Comparable<DataWord> {
// TODO not safe
public static final DataWord ZERO = new DataWord(
new byte[WORD_SIZE]); // don't push it in to the stack
private byte[] data = new byte[32];
private byte[] data = new byte[WORD_SIZE];

public DataWord() {
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public static DataWord ONE() {
}

public static DataWord ZERO() {
return new DataWord(new byte[32]);
return new DataWord(new byte[WORD_SIZE]);
}

public static DataWord of(byte num) {
Expand Down Expand Up @@ -309,7 +309,7 @@ public void bnot() {
// By : Holger
// From : http://stackoverflow.com/a/24023466/459349
public void add(DataWord word) {
byte[] result = new byte[32];
byte[] result = new byte[WORD_SIZE];
for (int i = 31, overflow = 0; i >= 0; i--) {
int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow;
result[i] = (byte) v;
Expand Down Expand Up @@ -395,7 +395,7 @@ public void sMod(DataWord word) {

public void addmod(DataWord word1, DataWord word2) {
if (word2.isZero()) {
this.data = new byte[32];
this.data = new byte[WORD_SIZE];
return;
}

Expand All @@ -406,7 +406,7 @@ public void addmod(DataWord word1, DataWord word2) {
public void mulmod(DataWord word1, DataWord word2) {

if (this.isZero() || word1.isZero() || word2.isZero()) {
this.data = new byte[32];
this.data = new byte[WORD_SIZE];
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static RocksDbSettings getSettings() {
}

public static RocksDbSettings initCustomSettings(int levelNumber, int compactThreads,
int blocksize, long maxBytesForLevelBase,
int blockSize, long maxBytesForLevelBase,
double maxBytesForLevelMultiplier, int level0FileNumCompactionTrigger,
long targetFileSizeBase,
int targetFileSizeMultiplier) {
Expand All @@ -61,7 +61,7 @@ public static RocksDbSettings initCustomSettings(int levelNumber, int compactThr
.withEnableStatistics(false)
.withLevelNumber(levelNumber)
.withCompactThreads(compactThreads)
.withBlockSize(blocksize)
.withBlockSize(blockSize)
.withMaxBytesForLevelBase(maxBytesForLevelBase)
.withMaxBytesForLevelMultiplier(maxBytesForLevelMultiplier)
.withLevel0FileNumCompactionTrigger(level0FileNumCompactionTrigger)
Expand Down
9 changes: 5 additions & 4 deletions common/src/main/java/org/tron/common/utils/ByteUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ByteUtil {

public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
public static final byte[] ZERO_BYTE_ARRAY = new byte[]{0};
public static final int WORD_SIZE = 32;


/**
Expand Down Expand Up @@ -274,7 +275,7 @@ public static byte[] stripLeadingZeroes(byte[] data) {
* @return Byte array of given size with a copy of the <code>src</code>
*/
public static byte[] copyToArray(BigInteger value) {
byte[] dest = ByteBuffer.allocate(32).array();
byte[] dest = ByteBuffer.allocate(WORD_SIZE).array();
byte[] src = ByteUtil.bigIntegerToBytes(value);
if (src != null) {
System.arraycopy(src, 0, dest, dest.length - src.length, src.length);
Expand Down Expand Up @@ -322,7 +323,7 @@ public static byte[] parseBytes(byte[] input, int offset, int len) {
* @param idx an index of the word starting from {@code 0}
*/
public static byte[] parseWord(byte[] input, int idx) {
return parseBytes(input, 32 * idx, 32);
return parseBytes(input, WORD_SIZE * idx, WORD_SIZE);
}

/**
Expand All @@ -333,7 +334,7 @@ public static byte[] parseWord(byte[] input, int idx) {
* @param offset an offset in {@code input} array to start parsing from
*/
public static byte[] parseWord(byte[] input, int offset, int idx) {
return parseBytes(input, offset + 32 * idx, 32);
return parseBytes(input, offset + WORD_SIZE * idx, WORD_SIZE);
}

public static boolean greater(byte[] bytes1, byte[] bytes2) {
Expand Down Expand Up @@ -410,4 +411,4 @@ public static void reverse(byte[] bytes) {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public Transaction createWitness(WitnessCreateContract contract) {
return walletBlockingStub.createWitness(contract);
}

public boolean broadcastTransaction(Transaction signaturedTransaction) {
Return response = walletBlockingStub.broadcastTransaction(signaturedTransaction);
public boolean broadcastTransaction(Transaction signedTransaction) {
Return response = walletBlockingStub.broadcastTransaction(signedTransaction);
return response.getResult();
}

Expand Down