Update floBlockchainAPI.js
This commit is contained in:
parent
f9f89d91d3
commit
e2d8abe347
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/* FLO Blockchain Operator to send/receive data from blockchain using API calls*/
|
/* FLO Blockchain Operator to send/receive data from blockchain using API calls*/
|
||||||
|
//version 2.2.1
|
||||||
(function(GLOBAL) {
|
(function(GLOBAL) {
|
||||||
const floBlockchainAPI = GLOBAL.floBlockchainAPI = {
|
const floBlockchainAPI = GLOBAL.floBlockchainAPI = {
|
||||||
|
|
||||||
@ -426,13 +427,18 @@
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => {
|
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => {
|
||||||
var newItems = response.totalItems - options.ignoreOld;
|
var newItems = response.totalItems - options.ignoreOld;
|
||||||
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=${newItems*2}`).then(
|
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=${newItems*2}`).then(response => {
|
||||||
response => {
|
|
||||||
if (options.limit <= 0)
|
if (options.limit <= 0)
|
||||||
options.limit = response.items.length;
|
options.limit = response.items.length;
|
||||||
var filteredData = [];
|
var filteredData = [];
|
||||||
for (let i = 0; i < (response.totalItems - options.ignoreOld) &&
|
let numToRead = response.totalItems - options.ignoreOld,
|
||||||
filteredData.length < options.limit; i++) {
|
unconfirmedCount = 0;
|
||||||
|
for (let i = 0; i < numToRead && filteredData.length < options.limit; i++) {
|
||||||
|
if (!response.items[i].confirmations) { //unconfirmed transactions
|
||||||
|
unconfirmedCount++;
|
||||||
|
numToRead++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (options.pattern) {
|
if (options.pattern) {
|
||||||
try {
|
try {
|
||||||
let jsonContent = JSON.parse(response.items[i].floData);
|
let jsonContent = JSON.parse(response.items[i].floData);
|
||||||
@ -492,7 +498,7 @@
|
|||||||
filteredData.push(response.items[i].floData);
|
filteredData.push(response.items[i].floData);
|
||||||
}
|
}
|
||||||
resolve({
|
resolve({
|
||||||
totalTxs: response.totalItems,
|
totalTxs: response.totalItems - unconfirmedCount,
|
||||||
data: filteredData
|
data: filteredData
|
||||||
});
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user