Reduce payload size for bootstrap. Fix invalid response to bootstrap. Bootstrap height now starts at N - min confs.

This commit is contained in:
Will O'Beirne 2019-03-04 14:40:37 -05:00
parent 51a065f5e8
commit 4779299fb3
No known key found for this signature in database
GPG Key ID: 44C190DB5DEAF9F6
3 changed files with 6 additions and 7 deletions

View File

@ -1,9 +1,6 @@
from datetime import datetime, timedelta
from grant.proposal.models import (
ProposalContribution,
proposal_contributions_schema,
)
from grant.proposal.models import ProposalContribution
from grant.utils.requests import blockchain_post
from grant.utils.enums import ContributionStatus
@ -17,8 +14,9 @@ def make_bootstrap_data():
.filter_by(status=ContributionStatus.CONFIRMED) \
.order_by(ProposalContribution.date_created.desc()) \
.first()
serialized_pending_contributions = list(map(lambda c: {"id": c.id}, pending_contributions))
return {
"pendingContributions": proposal_contributions_schema.dump(pending_contributions),
"pendingContributions": serialized_pending_contributions,
"latestTxId": latest_contribution.tx_id if latest_contribution else None,
}

View File

@ -11,4 +11,4 @@ blueprint = Blueprint("blockchain", __name__, url_prefix="/api/v1/blockchain")
def get_bootstrap_info():
print('Bootstrap data requested from blockchain watcher microservice...')
send_bootstrap_data()
return True
return {"message": "ok"}, 200

View File

@ -194,7 +194,8 @@ export async function getBootstrapBlockHeight(txid: string | undefined) {
try {
const tx = await node.gettransaction(txid);
const block = await node.getblock(tx.blockhash);
return block.height.toString();
const height = block.height - parseInt(env.MINIMUM_BLOCK_CONFIRMATIONS, 10);
return height.toString();
} catch(err) {
console.warn(`Attempted to get block height for tx ${txid} but failed with the following error:\n`, err);
console.warn('Falling back to hard-coded starter blocks');