
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
blockchain-state
Advanced tools
A writable stream for applications that consume blocks
This module should be used whenever you need to process blockchain blocks in order (e.g. wallets or any other application that needs to scan the blockchain). Handling of reorgs (switching from one blockchain fork to another) is simplified, and block sync progress is stored in a LevelUp database.
npm install blockchain-state
var BlockchainState = require('blockchain-state')
function add (block, tx, cb) {
// called when a block should be processed
cb() // call cb when done
}
function remove (block, tx, cb) {
// called when a block should be un-processed
cb() // call cb when done
}
var db = level('foo') // a LevelUp-compatible datastore
var state = new BlockchainState(add, remove, db)
// write blocks to the BlockchainState
// 'chain' is an instance of a Blockchain (from the
// 'blockchain-spv' module)
state.getHash(function (err, hash) {
if (err) return console.log(err)
// BlockchainState is a writable stream,
// so we can pipe blocks directly into it
chain.createReadStream({ from: hash }).pipe(state)
})
new BlockchainState(add, remove, db, [opts])
Creates a BlockchainState
which can process blocks. BlockchainState
is a writable stream, and expects an input of blocks in the format output by chain.createReadStream()
from the blockchain-spv
module.
add(block, tx, cb)
should be a function which will be called every time a new block should be processed. The arguments passed to it are:
block
: the block to be processedtx
: a database transaction, which may be used to modify the LevelUp database while ensuring consistency with the blockchain statecb
: a callback function that must be called when done processing the block (optionally with an error)remove(block, tx, cb)
is similar to add
, but is instead called whenever a block should be un-processed (when it is now in an invalid fork)
db
should be a LevelUp
instance where block data will be stored. The db should not be shared with another Blockchain (if you need to, use level-sublevel
to create a sub-section of your db).
state.getHash(callback)
Calls callback(err, hash)
with the hash of the block most recently processed by the BlockchainState
. If no blocks have been processed yet, hash
will be null
.
FAQs
A writable stream for applications that consume blocks
The npm package blockchain-state receives a total of 2 weekly downloads. As such, blockchain-state popularity was classified as not popular.
We found that blockchain-state demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.