Socket
Socket
Sign inDemoInstall

ethereum-bloom-filters

Package Overview
Dependencies
1
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

dist/utils.d.ts

21

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ethers_1 = require("ethers");
const utils_1 = require("./utils");
/**

@@ -15,3 +15,4 @@ * Returns true if the bloom is a valid bloom

}
if (/^(0x)?[0-9a-f]{512}$/.test(bloom) || /^(0x)?[0-9A-F]{512}$/.test(bloom)) {
if (/^(0x)?[0-9a-f]{512}$/.test(bloom) ||
/^(0x)?[0-9A-F]{512}$/.test(bloom)) {
return true;

@@ -30,5 +31,5 @@ }

if (typeof value === 'object' && value.constructor === Uint8Array) {
value = ethers_1.ethers.utils.hexlify(value);
value = utils_1.bytesToHex(value);
}
const hash = ethers_1.ethers.utils.keccak256(value).replace('0x', '');
const hash = utils_1.keccak256(value).replace('0x', '');
for (let i = 0; i < 12; i += 4) {

@@ -50,5 +51,5 @@ // calculate bit position in bloom filter that must be active

/**
* Code points to int
* @param codePoint The code point
*/
* Code points to int
* @param codePoint The code point
*/
function codePointToInt(codePoint) {

@@ -87,3 +88,4 @@ if (codePoint >= 48 && codePoint <= 57) {

// hence why we have 2 methods
const address = ethers_1.ethers.utils.padZeros(ethereumAddress, 32);
// (0x is not in the 2nd parameter of padleft so 64 chars is fine)
const address = utils_1.padLeft(ethereumAddress, 64);
return isInBloom(bloom, address);

@@ -135,3 +137,4 @@ }

}
else if (/^(0x)?[0-9a-f]{64}$/.test(topic) || /^(0x)?[0-9A-F]{64}$/.test(topic)) {
else if (/^(0x)?[0-9a-f]{64}$/.test(topic) ||
/^(0x)?[0-9A-F]{64}$/.test(topic)) {
return true;

@@ -138,0 +141,0 @@ }

{
"name": "ethereum-bloom-filters",
"version": "1.0.2",
"version": "1.0.3",
"description": "Ability to test bloom filters for ethereum.",

@@ -30,3 +30,3 @@ "main": "dist/index.js",

"dependencies": {
"ethers": "^4.0.37"
"js-sha3": "^0.8.0"
},

@@ -40,2 +40,2 @@ "devDependencies": {

}
}
}

@@ -5,2 +5,4 @@ # ethereum-bloom-filters

This package only has 1 dependency which is on `js-sha3` which has no dependencies on at all.
## Installation

@@ -14,3 +16,3 @@

### yarn:
### yarn:

@@ -38,8 +40,9 @@ ```js

```js
import {
isBloom,
isUserEthereumAddressInBloom, isContractAddressInBloom,
isTopicInBloom,
isInBloom
} from 'ethereum-bloom-filters'
import {
isBloom,
isUserEthereumAddressInBloom,
isContractAddressInBloom,
isTopicInBloom,
isInBloom
} from 'ethereum-bloom-filters';
```

@@ -59,3 +62,3 @@

A ethereum real life example in where this is useful is if you want to update a users balance on every new block so it stays as close to real time as possible. Without using a bloom filter on every new block you would have to force the balances even if that user may not of had any activity within that block. But if you use the logBlooms from the block you can test the bloom filter against the users ethereum address before you do any more slow operations, this will dramatically decrease the amount of calls you do as you will only be doing those extra operations if that ethereum address is within that block (minus the false positives outcome which will be negligible). This will be highly performant for your app.
A ethereum real life example in where this is useful is if you want to update a users balance on every new block so it stays as close to real time as possible. Without using a bloom filter on every new block you would have to force the balances even if that user may not of had any activity within that block. But if you use the logBlooms from the block you can test the bloom filter against the users ethereum address before you do any more slow operations, this will dramatically decrease the amount of calls you do as you will only be doing those extra operations if that ethereum address is within that block (minus the false positives outcome which will be negligible). This will be highly performant for your app.

@@ -62,0 +65,0 @@ ## Functions

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc