本文整理汇总了Java中org.ethereum.core.Bloom类的典型用法代码示例。如果您正苦于以下问题:Java Bloom类的具体用法?Java Bloom怎么用?Java Bloom使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Bloom类属于org.ethereum.core包,在下文中一共展示了Bloom类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBlooms
import org.ethereum.core.Bloom; //导入依赖的package包/类
private void initBlooms() {
if (filterBlooms != null) {
return;
}
List<byte[][]> addrAndTopics = new ArrayList<>(topics);
addrAndTopics.add(contractAddresses);
filterBlooms = new Bloom[addrAndTopics.size()][];
for (int i = 0; i < addrAndTopics.size(); i++) {
byte[][] orTopics = addrAndTopics.get(i);
if (orTopics == null || orTopics.length == 0) {
filterBlooms[i] = new Bloom[] {new Bloom()}; // always matches
} else {
filterBlooms[i] = new Bloom[orTopics.length];
for (int j = 0; j < orTopics.length; j++) {
filterBlooms[i][j] = Bloom.create(SHA3Helper.sha3(orTopics[j]));
}
}
}
}
示例2: matchBloom
import org.ethereum.core.Bloom; //导入依赖的package包/类
public boolean matchBloom(Bloom blockBloom) {
initBlooms();
for (Bloom[] andBloom : filterBlooms) {
boolean orMatches = false;
for (Bloom orBloom : andBloom) {
if (blockBloom.matches(orBloom)) {
orMatches = true;
break;
}
}
if (!orMatches) {
return false;
}
}
return true;
}
示例3: saveHeader
import org.ethereum.core.Bloom; //导入依赖的package包/类
@Test
public void saveHeader() {
BlockStore store = new BlockStore();
BlockHeader blockHeader = new BlockHeader(new byte[]{},
new byte[]{},
new byte[]{},
new Bloom().getData(),
new byte[]{},
1,
new byte[]{},
0,
0,
new byte[]{},
new byte[]{},
new byte[]{},
new byte[]{},
new byte[]{},
0
);
store.saveHeader(blockHeader);
Assert.assertTrue(store.hasHeader(blockHeader.getHash()));
}
示例4: removeHeader
import org.ethereum.core.Bloom; //导入依赖的package包/类
@Test
public void removeHeader() {
BlockStore store = new BlockStore();
BlockHeader blockHeader = new BlockHeader(new byte[]{},
new byte[]{},
new byte[]{},
new Bloom().getData(),
new byte[]{},
1,
new byte[]{},
0,
0,
new byte[]{},
new byte[]{},
new byte[]{},
new byte[]{},
new byte[]{},
0
);
store.saveHeader(blockHeader);
store.removeHeader(blockHeader);
Assert.assertFalse(store.hasHeader(blockHeader.getHash()));
}
示例5: initBlooms
import org.ethereum.core.Bloom; //导入依赖的package包/类
private void initBlooms() {
if (filterBlooms != null) return;
List<byte[][]> addrAndTopics = new ArrayList<>(topics);
addrAndTopics.add(contractAddresses);
filterBlooms = new Bloom[addrAndTopics.size()][];
for (int i = 0; i < addrAndTopics.size(); i++) {
byte[][] orTopics = addrAndTopics.get(i);
if (orTopics == null || orTopics.length == 0) {
filterBlooms[i] = new Bloom[] {new Bloom()}; // always matches
} else {
filterBlooms[i] = new Bloom[orTopics.length];
for (int j = 0; j < orTopics.length; j++) {
filterBlooms[i][j] = Bloom.create(sha3(orTopics[j]));
}
}
}
}
示例6: calculateLogsBloom
import org.ethereum.core.Bloom; //导入依赖的package包/类
private static byte[] calculateLogsBloom(List<TransactionReceipt> receipts) {
Bloom logBloom = new Bloom();
for (TransactionReceipt receipt : receipts) {
logBloom.or(receipt.getBloomFilter());
}
return logBloom.getData();
}
示例7: getBloom
import org.ethereum.core.Bloom; //导入依赖的package包/类
public Bloom getBloom() {
Bloom ret = Bloom.create(HashUtil.sha3(address));
for (DataWord topic : topics) {
byte[] topicData = topic.getData();
ret.or(Bloom.create(HashUtil.sha3(topicData)));
}
return ret;
}
示例8: matchBloom
import org.ethereum.core.Bloom; //导入依赖的package包/类
public boolean matchBloom(Bloom blockBloom) {
initBlooms();
for (Bloom[] andBloom : filterBlooms) {
boolean orMatches = false;
for (Bloom orBloom : andBloom) {
if (blockBloom.matches(orBloom)) {
orMatches = true;
break;
}
}
if (!orMatches) return false;
}
return true;
}
示例9: testBadBlockEncoding1
import org.ethereum.core.Bloom; //导入依赖的package包/类
@Test(expected = ArithmeticException.class)
public void testBadBlockEncoding1() {
List<Transaction> txs = new ArrayList<>();
Transaction tx = new Transaction(
BigInteger.ZERO.toByteArray(),
BigInteger.ONE.toByteArray(),
BigInteger.valueOf(21000).toByteArray(),
new ECKey().getAddress(),
BigInteger.valueOf(1000).toByteArray(),
null);
txs.add(tx);
byte[] bigBadByteArray = new byte[10000];
Arrays.fill(bigBadByteArray , (byte) -1);
FreeBlock fblock = new FreeBlock(
PegTestUtils.createHash3().getBytes(), // parent hash
EMPTY_LIST_HASH, // uncle hash
PegTestUtils.createHash3().getBytes(), // coinbase
new Bloom().getData(), // logs bloom
BigInteger.ONE.toByteArray(), // difficulty
bigBadByteArray ,
bigBadByteArray , // gasLimit
bigBadByteArray ,// gasUsed
bigBadByteArray , //timestamp
new byte[0], // extraData
new byte[0], // mixHash
new byte[]{0}, // provisory nonce
HashUtil.EMPTY_TRIE_HASH, // receipts root
BlockChainImpl.calcTxTrie(txs), // transaction root
HashUtil.EMPTY_TRIE_HASH, //EMPTY_TRIE_HASH, // state root
txs, // transaction list
null, // uncle list
BigInteger.TEN.toByteArray(),
new byte[0]
);
// Now decode, and re-encode
Block parsedBlock = new Block(fblock.getEncoded());
// must throw java.lang.ArithmeticException
parsedBlock.getGasLimit(); // forced parse
}