Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use current block - 3 reference for broadcast tx #161

Merged
merged 1 commit into from
Jun 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/broadcast/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ steemBroadcast._prepareTransaction = function steemBroadcast$_prepareTransaction
.then((properties) => {
// Set defaults on the transaction
const chainDate = new Date(properties.time + 'Z');
return Object.assign({
ref_block_num: properties.head_block_number & 0xFFFF,
ref_block_prefix: new Buffer(properties.head_block_id, 'hex').readUInt32LE(4),
expiration: new Date(
chainDate.getTime() +
const refBlockNum = (properties.head_block_number - 3) & 0xFFFF;
return steemApi.getBlockAsync(properties.head_block_number - 2).then((block) => {
const headBlockId = block.previous;
return Object.assign({
ref_block_num: refBlockNum,
ref_block_prefix: new Buffer(headBlockId, 'hex').readUInt32LE(4),
expiration: new Date(
chainDate.getTime() +
60 * 1000
),
}, tx);
),
}, tx);
});
});
};

Expand Down