Java Code Examples for org.ethereum.util.FastByteComparisons#equal()
The following examples show how to use
org.ethereum.util.FastByteComparisons#equal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgramExecutorImpl.java From nuls-v2 with MIT License | 6 votes |
@Override public ProgramResult stop(long blockNumber, byte[] address, byte[] sender) { checkThread(); AccountState accountState = repository.getAccountState(address); if (accountState == null) { return revert("can't find contract"); } if (!FastByteComparisons.equal(sender, accountState.getOwner())) { return revert("only the owner can stop the contract"); } BigInteger balance = getTotalBalance(address, null); if (BigInteger.ZERO.compareTo(balance) != 0) { return revert("contract balance is not zero"); } if (BigInteger.ZERO.compareTo(accountState.getNonce()) >= 0) { return revert("contract has stopped"); } this.blockNumber = blockNumber; repository.setNonce(address, BigInteger.ZERO); ProgramResult programResult = new ProgramResult(); return programResult; }
Example 2
Source File: ProgramExecutorImpl.java From nuls with MIT License | 6 votes |
@Override public ProgramResult stop(byte[] address, byte[] sender) { checkThread(); AccountState accountState = repository.getAccountState(address); if (accountState == null) { return revert("can't find contract"); } if (!FastByteComparisons.equal(sender, accountState.getOwner())) { return revert("only the owner can stop the contract"); } BigInteger balance = getTotalBalance(address, null); if (BigInteger.ZERO.compareTo(balance) != 0) { return revert("contract balance is not zero"); } if (BigInteger.ZERO.compareTo(accountState.getNonce()) >= 0) { return revert("contract has stopped"); } repository.setNonce(address, BigInteger.ZERO); ProgramResult programResult = new ProgramResult(); return programResult; }
Example 3
Source File: TrieImpl.java From nuls-v2 with MIT License | 5 votes |
@Override public void setRoot(byte[] root) { if (root != null && !FastByteComparisons.equal(root, EMPTY_TRIE_HASH)) { this.root = new Node(root); } else { this.root = null; } }
Example 4
Source File: TrieImpl.java From nuls-v2 with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TrieImpl trieImpl1 = (TrieImpl) o; return FastByteComparisons.equal(getRootHash(), trieImpl1.getRootHash()); }
Example 5
Source File: ChainItem.java From nuls-v2 with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ChainItem that = (ChainItem) o; return FastByteComparisons.equal(hash, that.hash); }
Example 6
Source File: BlockHeader.java From nuls-v2 with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BlockHeader that = (BlockHeader) o; return FastByteComparisons.equal(getHash(), that.getHash()); }
Example 7
Source File: TrieImpl.java From nuls with MIT License | 5 votes |
@Override public void setRoot(byte[] root) { if (root != null && !FastByteComparisons.equal(root, EMPTY_TRIE_HASH)) { this.root = new Node(root); } else { this.root = null; } }
Example 8
Source File: TrieImpl.java From nuls with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TrieImpl trieImpl1 = (TrieImpl) o; return FastByteComparisons.equal(getRootHash(), trieImpl1.getRootHash()); }
Example 9
Source File: ChainItem.java From nuls with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ChainItem that = (ChainItem) o; return FastByteComparisons.equal(hash, that.hash); }
Example 10
Source File: BlockHeader.java From nuls with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BlockHeader that = (BlockHeader) o; return FastByteComparisons.equal(getHash(), that.getHash()); }
Example 11
Source File: RepositoryImpl.java From nuls-v2 with MIT License | 4 votes |
@Override public synchronized byte[] getCode(byte[] addr) { byte[] codeHash = getCodeHash(addr); return codeHash == null || FastByteComparisons.equal(codeHash, HashUtil.EMPTY_DATA_HASH) ? ByteUtil.EMPTY_BYTE_ARRAY : codeCache.get(codeKey(codeHash, addr)); }
Example 12
Source File: ChainItem.java From nuls-v2 with MIT License | 4 votes |
boolean isParentOf(ChainItem that) { return FastByteComparisons.equal(hash, that.parentHash); }
Example 13
Source File: AccountState.java From nuls-v2 with MIT License | 4 votes |
public boolean isEmpty() { return FastByteComparisons.equal(codeHash, EMPTY_DATA_HASH) && BigInteger.ZERO.equals(balance) && BigInteger.ZERO.equals(nonce); }
Example 14
Source File: RepositoryImpl.java From nuls with MIT License | 4 votes |
@Override public synchronized byte[] getCode(byte[] addr) { byte[] codeHash = getCodeHash(addr); return codeHash == null || FastByteComparisons.equal(codeHash, HashUtil.EMPTY_DATA_HASH) ? ByteUtil.EMPTY_BYTE_ARRAY : codeCache.get(codeKey(codeHash, addr)); }
Example 15
Source File: ChainItem.java From nuls with MIT License | 4 votes |
boolean isParentOf(ChainItem that) { return FastByteComparisons.equal(hash, that.parentHash); }
Example 16
Source File: AccountState.java From nuls with MIT License | 4 votes |
public boolean isEmpty() { return FastByteComparisons.equal(codeHash, EMPTY_DATA_HASH) && BigInteger.ZERO.equals(balance) && BigInteger.ZERO.equals(nonce); }