Exchange transactions with peers
npm install bitcoin-inventory
var Inventory =// "peers" is a PeerGroup or Peer from the `bitcoin-net` packagevar inv =// get a tx that was sent to usinv // returns tx// add a tx and announce its hash to our peersinvinvinv
Inventory handles the exchange of Bitcoin transactions with peers.
When a peer discovers a new transaction, they send us a message (
inv) announcing its hash. If we have not yet seen this transaction,
Inventory will request it from the peer and add it to the inventory.
If we create a new transaction,
Inventory will announce the hash to our peers, and send the transaction data to them if they request it.
new Inventory(peers, [opts])
Inventory which listens for and fetches new transactions from peers, and announces transactions to peers.
Transactions are only kept in the
Inventory for a limited amount of time, after which they are automatically pruned. (The amount of time is configurable via the
peers should be an instance of
Peer, from the
opts may be an object containing:
120000(2 minutes)) - the amount of time to keep transactions in the inventory before pruning them (in ms)
Returns the transaction from the inventory with the specified hash (which is a
tx to the inventory, and announces its hash to the peers. Also listens for peers to request the full transaction from us.
Closes the inventory and clears timers.