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

Ledger unconfirmed balance fix #3495

Merged
merged 2 commits into from
Aug 28, 2016
Merged
Show file tree
Hide file tree
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: 15 additions & 3 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const doAction = (action) => {
*/
var init = () => {
try {
ledgerInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_INFO_DEBUG)
ledgerInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_CLIENT_DEBUG)
publisherInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_PUBLISHER_DEBUG)

appDispatcher.register(doAction)
Expand Down Expand Up @@ -471,7 +471,12 @@ var updatePublisherInfo = () => {
publisherInfo.synopsis = synopsisNormalizer()

if (publisherInfo._internal.debugP) {
console.log('\nupdatePublisherInfo: ' + JSON.stringify(underscore.omit(publisherInfo, [ '_internal' ])))
data = []
publisherInfo.synopsis.forEach((entry) => {
data.push(underscore.extend(underscore.omit(entry, [ 'faviconURL' ]), { faviconURL: entry.faviconURL && '...' }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the "real" string tends to be a long base64 value. all we really need to know is whether a value is present or not, the "..." serves that purpose... otherwise, you get a lot of scrolling in the console window with very little useful content.

})

console.log('\nupdatePublisherInfo: ' + JSON.stringify(data, null, 2))
}

appActions.updatePublisherInfo(underscore.omit(publisherInfo, [ '_internal' ]))
Expand Down Expand Up @@ -976,12 +981,19 @@ var getBalance = () => {

ledgerBalance.getBalance(ledgerInfo.address, underscore.extend({ balancesP: true }, client.options),
(err, provider, result) => {
var unconfirmed
var info = ledgerInfo._internal.paymentInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious why unconfirmed needs to be in ledgerInfo._internal if it already exists in ledgerInfo


if (err) return console.log('ledger balance error: ' + JSON.stringify(err, null, 2))

if (typeof result.unconfirmed === 'undefined') return

if (result.unconfirmed > 0) {
ledgerInfo.unconfirmed = (result.unconfirmed / 1e8).toFixed(4)
unconfirmed = (result.unconfirmed / 1e8).toFixed(4)
if ((info || ledgerInfo).unconfirmed === unconfirmed) return

ledgerInfo.unconfirmed = unconfirmed
if (info) info.unconfirmed = ledgerInfo.unconfirmed
if (clientOptions.verboseP) console.log('\ngetBalance refreshes ledger info: ' + ledgerInfo.unconfirmed)
return updateLedgerInfo()
}
Expand Down
2 changes: 1 addition & 1 deletion docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ WindowStore
minutesSpent: number, // e.g., 3
secondsSpent: number, // e.g., 4
score: number, // float indicating the current score
percentage: number, // 0, 1, ... 100
percentage: number, // i.e., 0, 1, ... 100
publisherURL: string, // publisher site, e.g., "https://wikipedia.org/"
faviconURL: string // i.e., "data:image/...;base64,..."
}
Expand Down