Skip to content

Instantly share code, notes, and snippets.

@tuxcanfly
Last active January 26, 2020 06:22
Show Gist options
  • Save tuxcanfly/40abdb79e9c6f7cbdfad70da2769bf2d to your computer and use it in GitHub Desktop.
Save tuxcanfly/40abdb79e9c6f7cbdfad70da2769bf2d to your computer and use it in GitHub Desktop.
'use strict';
const FullNode = require('./lib/node/fullnode');
const NetAddress = require('./lib/net/netaddress.js');
const Network = require('./lib/protocol/network.js');
const random = require('bcrypto/lib/random');
const Logger = require('blgr');
const bs32 = require('bs32');
const rules = require('./lib/covenants/rules');
const key = bs32.decode('aorsxa4ylaacshipyjkfbvzfkh3jhh4yowtoqdt64nzemqtiw2whk');
async function sleep(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
(async () => {
const node = new FullNode({
'logger': new Logger({
console: true,
level: 'debug'
}),
'network': 'regtest',
'http-port': 15037,
'ns-port': 26349,
'rs-port': 26330,
'port': 15038
});
await node.open();
const peer = await node.pool.createOutbound(new NetAddress({
'host': '127.0.0.1',
'port': 14038,
'key': key
}));
await sleep(2000);
const root = await node.chain.getSafeRoot();
const hash = rules.hashString('google');
// peer.nameMap.set(hash, Date.now());
// TODO: this should prevent remote from getting banned but throws instead...
// just comment out peer.increaseBan() handleProof for now.
for (let i=0; ;i++) {
console.log('%d: sending getproof', i);
peer.sendGetProof(root, hash);
}
})();
@tuxcanfly
Copy link
Author

awesome, I'm stealing this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment