[chore] update newBlockHeaders

@types
neeboo 6 years ago
parent fcf21c534f
commit 7b41bae315
  1. 8
      examples/temp.html
  2. 19
      examples/testGanache.js
  3. 2
      packages/harmony-core/src/blockchain.ts
  4. 7
      packages/harmony-network/src/providers/ws.ts

@ -39,14 +39,14 @@
<script>
const harmony= new HarmonyJs.Harmony('ws://localhost:18545',1);
// console.log()
const diu = async () => {
const p= await harmony.blockchain.newPendingTransactions()
const biubiubiu = async () => {
const p= await harmony.blockchain.newBlockHeaders()
// harmony.blockchain.newBlockHeaders()
@ -67,7 +67,7 @@
}
setTimeout(diu, 100);
setTimeout(biubiubiu, 100);

@ -226,16 +226,13 @@ async function main() {
}
server.listen(port, function(err, blockchain) {
harmony.blockchain.newPendingTransactions().then((p) => {
p.onData(async (res) => {
const txn = await harmony.blockchain.getTransactionByHash({
txnHash: res.params.result,
});
console.log(txn);
});
});
setTimeout(() => main(), 5000);
// console.log(wsHarmony.provider.connected);
});
// setTimeout(() => {
// harmony.blockchain.newPendingTransactions().then((emitter) => {
// emitter.on('data', (data) => {
// console.log('-------- ws data --------');
// console.log(data);
// console.log('-------- ws data --------');
// });
// });
// }, 1000);

@ -316,7 +316,7 @@ class Blockchain extends HarmonyCore {
if (this.messenger.provider instanceof WSProvider) {
return this.messenger.subscribe(
RPCMethod.Subscribe,
['newBlockHeaders'],
['newHeads'],
this.chainPrefix,
);
} else {

@ -70,6 +70,13 @@ class WSProvider extends BaseSocket {
}
}
reconnect() {
setTimeout(() => {
this.removeAllSocketListeners();
this.connection = this.createWebsocketProvider(this.url, this.options);
this.registerEventListeners();
}, 5000);
}
isConnecting() {
return this.connection.readyState === this.connection.CONNECTING;
}

Loading…
Cancel
Save