Skip to content
Snippets Groups Projects
Commit 607ec6be authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] Refactoring: type FileDAL.txsDAL

parent dd75c1a9
Branches
Tags
No related merge requests found
...@@ -23,7 +23,7 @@ import {DBPeer} from "./sqliteDAL/PeerDAL" ...@@ -23,7 +23,7 @@ import {DBPeer} from "./sqliteDAL/PeerDAL"
import {TransactionDTO} from "../dto/TransactionDTO" import {TransactionDTO} from "../dto/TransactionDTO"
import {CertDAL, DBCert} from "./sqliteDAL/CertDAL" import {CertDAL, DBCert} from "./sqliteDAL/CertDAL"
import {DBWallet, WalletDAL} from "./sqliteDAL/WalletDAL" import {DBWallet, WalletDAL} from "./sqliteDAL/WalletDAL"
import {DBTx} from "./sqliteDAL/TxsDAL" import {DBTx, TxsDAL} from "./sqliteDAL/TxsDAL"
import {DBBlock} from "../db/DBBlock" import {DBBlock} from "../db/DBBlock"
import {DBMembership, MembershipDAL} from "./sqliteDAL/MembershipDAL" import {DBMembership, MembershipDAL} from "./sqliteDAL/MembershipDAL"
import {MerkleDTO} from "../dto/MerkleDTO" import {MerkleDTO} from "../dto/MerkleDTO"
...@@ -67,7 +67,7 @@ export class FileDAL { ...@@ -67,7 +67,7 @@ export class FileDAL {
metaDAL:MetaDAL metaDAL:MetaDAL
peerDAL:any peerDAL:any
blockDAL:any blockDAL:any
txsDAL:any txsDAL:TxsDAL
statDAL:StatDAL statDAL:StatDAL
idtyDAL:IdentityDAL idtyDAL:IdentityDAL
certDAL:CertDAL certDAL:CertDAL
......
...@@ -251,7 +251,12 @@ export class TxsDAL extends AbstractSQLite<DBTx> { ...@@ -251,7 +251,12 @@ export class TxsDAL extends AbstractSQLite<DBTx> {
return this.query('SELECT * FROM sandbox_txs LIMIT ' + (this.sandbox.maxSize), []) return this.query('SELECT * FROM sandbox_txs LIMIT ' + (this.sandbox.maxSize), [])
} }
sandbox = new SandBox(constants.SANDBOX_SIZE_TRANSACTIONS, this.getSandboxTxs.bind(this), (compared:DBTx, reference:DBTx) => { sandbox:SandBox<{ issuers: string[], output_base:number, output_amount:number }> = new SandBox(
constants.SANDBOX_SIZE_TRANSACTIONS,
() => this.getSandboxTxs(),
(compared:{ issuers: string[], output_base:number, output_amount:number },
reference:{ issuers: string[], output_base:number, output_amount:number }
) => {
if (compared.output_base < reference.output_base) { if (compared.output_base < reference.output_base) {
return -1; return -1;
} }
......
...@@ -127,14 +127,25 @@ export class TransactionBinding extends AbstractController { ...@@ -127,14 +127,25 @@ export class TransactionBinding extends AbstractController {
async getPending(): Promise<HttpTxPending> { async getPending(): Promise<HttpTxPending> {
const pending = await this.server.dal.getTransactionsPending(); const pending = await this.server.dal.getTransactionsPending();
const res = { return {
"currency": this.conf.currency, currency: this.conf.currency,
"pending": pending pending: pending.map(t => {
}; const tx = TransactionDTO.fromJSONObject(t)
pending.map(function(tx:any, index:number) { return {
pending[index] = _.omit(TransactionDTO.fromJSONObject(tx).json(), 'currency', 'raw'); version: tx.version,
}); issuers: tx.issuers,
return res; inputs: tx.inputs,
unlocks: tx.unlocks,
outputs: tx.outputs,
comment: tx.comment,
locktime: tx.locktime,
blockstamp: tx.blockstamp,
blockstampTime: tx.blockstampTime,
signatures: tx.signatures,
hash: tx.hash
}
})
}
} }
private async getFilteredHistory(pubkey:string, filter:any): Promise<HttpTxHistory> { private async getFilteredHistory(pubkey:string, filter:any): Promise<HttpTxHistory> {
......
...@@ -772,6 +772,18 @@ export interface HttpTransaction { ...@@ -772,6 +772,18 @@ export interface HttpTransaction {
hash: string hash: string
} }
export interface HttpTransactionPending {
version: number
issuers: string[]
inputs: string[]
unlocks: string[]
outputs: string[]
comment: string
locktime: number
signatures: string[]
hash: string
}
export const Source = { export const Source = {
"type": String, "type": String,
"noffset": Number, "noffset": Number,
...@@ -867,7 +879,7 @@ export const TxPending = { ...@@ -867,7 +879,7 @@ export const TxPending = {
export interface HttpTxPending { export interface HttpTxPending {
currency: string currency: string
pending: HttpTransaction[] pending: HttpTransactionPending[]
} }
export const UD = { export const UD = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment