Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/fix-block-wait' into fix-block-wait
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/externalApis/tenderdash/blockchainListener/BlockchainListener.js
#	lib/grpcServer/handlers/platform/waitForStateTransitionResultHandlerFactory.js
  • Loading branch information
shumkov committed Feb 16, 2021
2 parents 8ff0aa8 + e22be10 commit 4be94d1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
3 changes: 0 additions & 3 deletions lib/grpcServer/handlers/handleAbciResponseError.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ function handleAbciResponseError(error) {
const message = error.getMessage();
const data = error.getData();

console.log(code, message, data);

switch (code) {
case 7: // UNAVAILABLE
throw new UnavailableGrpcError(message, data);
Expand All @@ -42,7 +40,6 @@ function handleAbciResponseError(error) {
throw new DeadlineExceededGrpcError(data.toString(), {});
}

console.log('Whopie doopie');
const e = new Error(message);

throw new InternalGrpcError(e, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,10 @@ function broadcastStateTransitionHandlerFactory(rpcClient, handleAbciResponseErr
throw new InvalidArgumentGrpcError('State Transition is not specified');
}

const hashString = crypto.createHash('sha256')
.update(stByteArray)
.digest()
.toString('hex');

console.log(`[${new Date()}]: broadcasting ST ${hashString}`);

const tx = Buffer.from(stByteArray).toString('base64');

console.log(`[${new Date()}]: Doing broadcast tx sync ${hashString}`);
const { result } = await rpcClient.request('broadcast_tx_sync', { tx });

console.log(`[${new Date()}]: Got sync broadcast result for ${hashString}`);
console.dir(result);

const { error: jsonRpcError } = result;

if (jsonRpcError) {
Expand All @@ -67,18 +56,14 @@ function broadcastStateTransitionHandlerFactory(rpcClient, handleAbciResponseErr
throw error;
}

console.log(`[${new Date()}]: Checking for ABCI errors ${hashString}`);
if (result.code !== undefined && result.code !== 0) {
console.log(`[${new Date()}]: ABCI error found ${hashString}:`);
const { error: abciError } = JSON.parse(result.log);
console.dir(abciError);

handleAbciResponseError(
new AbciResponseError(result.code, abciError),
);
}

console.log(`[${new Date()}]: ST ${hashString} broadcasted`);
return new BroadcastStateTransitionResponse();
}

Expand Down

0 comments on commit 4be94d1

Please sign in to comment.