Skip to content

Commit

Permalink
revert back to b2p2p until genesis fixes rolled out
Browse files Browse the repository at this point in the history
  • Loading branch information
synfonaut committed Jan 19, 2020
1 parent f1c5280 commit 708459e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
24 changes: 18 additions & 6 deletions dist.js
Expand Up @@ -49,7 +49,7 @@ function sleep(ms) {

const log$1 = require("debug")("hummingbird");

const { Peer, Messages } = require("bsv-p2p");
const { Peer, Messages } = require("b2p2p");


const messages = new Messages({ Block: bsv.Block, BlockHeader: bsv.BlockHeader, Transaction: bsv.Transaction, MerkleBlock: bsv.MerkleBlock });
Expand Down Expand Up @@ -328,16 +328,22 @@ class Hummingbird {
async onmempool(tx) {
for (const state_machine of this.state_machines) {
if (state_machine.onmempool) {
await state_machine.onmempool(tx);
if (!await state_machine.onmempool(tx)) {
throw new Error("error processing onmempool tx");
}
} else {
await state_machine.ontransaction(tx);
if (!await state_machine.ontransaction(tx)) {
throw new Error("error processing ontransaction tx");
}
}
}
}

async ontransaction(tx) {
for (const state_machine of this.state_machines) {
await state_machine.ontransaction(tx);
if (!await state_machine.ontransaction(tx)) {
throw new Error("error processing ontransaction tx");
}
}
}

Expand All @@ -355,10 +361,16 @@ class Hummingbird {
state_machine.log(`processing block ${block.header.height} with ${block.txs.length} txs`);
let start = Date.now();
if (state_machine.ontransactions) {
await state_machine.ontransactions(block.txs, block);
if (!await state_machine.ontransactions(block.txs, block)) {
state_machine.log(`error processing block ${block.header.height}`);
throw new Error(`error processing block ${block.header.height}`);
}
} else {
for (const tx of block.txs) {
await state_machine.ontransaction(tx);
if (!await state_machine.ontransaction(tx)) {
state_machine.log(`error processing block ${block.header.height}`);
throw new Error(`error processing block ${block.header.height}`);
}
}
}
let diff = Date.now() - start;
Expand Down
2 changes: 1 addition & 1 deletion index.js
@@ -1,6 +1,6 @@
const log = require("debug")("hummingbird");

const { Peer, Messages } = require("bsv-p2p");
const { Peer, Messages } = require("b2p2p");
import bsv from "bsv"
import RPCClient from "bitcoind-rpc"
import txo from "txo"
Expand Down
6 changes: 3 additions & 3 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "hummingbird-bitcoin",
"version": "0.1.0",
"version": "0.1.1",
"description": "A Real-time Bitcoin Application Framework",
"main": "dist.js",
"scripts": {
Expand All @@ -18,11 +18,11 @@
"mocha": "6.2.2"
},
"peerDependencies": {
"bsv": "^1.0.0"
"bsv": "^1.2.0"
},
"dependencies": {
"bitcoind-rpc": "0.8.1",
"bsv-p2p": "github:deanmlittle/bsv-p2p",
"b2p2p": "0.0.1",
"debug": "4.1.1",
"mongodb": "3.3.4",
"promise-queue": "2.2.5",
Expand Down

0 comments on commit 708459e

Please sign in to comment.