-
Notifications
You must be signed in to change notification settings - Fork 286
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
Consolidate core-api's repos into core-database & core-database-postgres #2107
Merged
faustbrian
merged 20 commits into
ArkEcosystem:2.3
from
paroxysm:feat/refactor-core-api-repos
Feb 20, 2019
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c3ce67c
feature: introduce transactions and blocks business repos. The idea i…
paroxysm 00ff55a
feature: implement the BlockBusinessRepo logic. And the search method…
paroxysm 1ebd0c3
Merge remote-tracking branch 'arkecosystem/develop' into feat/refacto…
paroxysm 86cd3b4
Merge remote-tracking branch 'arkecosystem/develop' into feat/refacto…
paroxysm e4b15d5
feature: implement TransactionsBusinessRepo, along with data-layer si…
paroxysm 15346c6
feature: Use business repos on core-api v2 api
paroxysm 43ad082
refactor: rename repo properties on the databaseService to use camel-…
paroxysm 2d66fd5
refactor: added 'findLastByPublicKey' method that I forgot to add
paroxysm 17e4ec4
fix: a failing test in core-api transactions.test.ts
paroxysm 0dc9b68
fix: failing tests in core-database
paroxysm 4667809
fix: findByTypeAndId
paroxysm 5c2270a
Merge remote-tracking branch 'arkecosystem/develop' into feat/refacto…
paroxysm f2a5a3a
Merge remote-tracking branch 'arkecosystem/develop' into feat/refacto…
paroxysm 46f7289
fix: compile-error caused by merge
paroxysm cb8f3d9
refactor: move 'getColumnSet', 'getSearchableFields' and 'getName' to…
paroxysm 4a54279
Merge remote-tracking branch 'arkecosystem/develop' into feat/refacto…
paroxysm f3daf4a
refactor: inline some variables
paroxysm 1b72e9e
fix: had mistakely removed support for 'senderId' parameter...
paroxysm a941c8d
Merge remote-tracking branch 'arkecosystem/develop' into feat/refacto…
paroxysm c16943a
chore: remove comment
paroxysm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feature: introduce transactions and blocks business repos. The idea i…
…s to have external modules interact with the business repos. The business repos optionally perform some business logic, and then call into the database repos
- Loading branch information
commit c3ce67cf1094e98961a5216bc48cafac193b19bb
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,119 @@ | ||
import { Database } from "@arkecosystem/core-interfaces"; | ||
import { bignumify } from "@arkecosystem/core-utils"; | ||
import { Model } from "./model"; | ||
|
||
export class Block extends Model { | ||
/** | ||
* The table associated with the model. | ||
* @return {String} | ||
*/ | ||
public getTable() { | ||
return "blocks"; | ||
} | ||
|
||
/** | ||
* The read-only structure with query-formatting columns. | ||
* @return {Object} | ||
*/ | ||
public getColumnSet() { | ||
return this.createColumnSet([ | ||
private readonly columnsDescriptor: any[]; | ||
|
||
constructor(pgp) { | ||
|
||
super(pgp); | ||
|
||
this.columnsDescriptor = [ | ||
{ | ||
name: "id", | ||
supportedOperators: [ Database.SearchOperator.OP_EQ ] | ||
}, | ||
{ | ||
name: "version", | ||
supportedOperators: [ Database.SearchOperator.OP_EQ ] | ||
}, | ||
{ | ||
name: "timestamp", | ||
supportedOperators: [ Database.SearchOperator.OP_LTE, Database.SearchOperator.OP_GTE ] | ||
}, | ||
{ | ||
name: "previous_block", | ||
prop: "previousBlock", | ||
def: null, | ||
supportedOperators: [ Database.SearchOperator.OP_EQ ] | ||
}, | ||
{ | ||
name: "height", | ||
supportedOperators: [ Database.SearchOperator.OP_LTE, Database.SearchOperator.OP_GTE ] | ||
}, | ||
{ | ||
name: "number_of_transactions", | ||
prop: "numberOfTransactions", | ||
supportedOperators: [ Database.SearchOperator.OP_LTE, Database.SearchOperator.OP_GTE ] | ||
}, | ||
{ | ||
name: "total_amount", | ||
prop: "totalAmount", | ||
init: col => bignumify(col.value).toFixed(), | ||
supportedOperators: [ Database.SearchOperator.OP_LTE, Database.SearchOperator.OP_GTE ] | ||
}, | ||
{ | ||
name: "total_fee", | ||
prop: "totalFee", | ||
init: col => bignumify(col.value).toFixed(), | ||
supportedOperators: [ Database.SearchOperator.OP_LTE, Database.SearchOperator.OP_GTE ] | ||
}, | ||
{ | ||
name: "reward", | ||
init: col => bignumify(col.value).toFixed(), | ||
supportedOperators: [ Database.SearchOperator.OP_LTE, Database.SearchOperator.OP_GTE ] | ||
}, | ||
{ | ||
name: "payload_length", | ||
prop: "payloadLength", | ||
supportedOperators: [ Database.SearchOperator.OP_LTE, Database.SearchOperator.OP_GTE ] | ||
}, | ||
{ | ||
name: "payload_hash", | ||
prop: "payloadHash", | ||
supportedOperators: [ Database.SearchOperator.OP_EQ ] | ||
}, | ||
{ | ||
name: "generator_public_key", | ||
prop: "generatorPublicKey", | ||
supportedOperators: [ Database.SearchOperator.OP_EQ ] | ||
}, | ||
{ | ||
name: "block_signature", | ||
prop: "blockSignature", | ||
}, | ||
]); | ||
supportedOperators: [ Database.SearchOperator.OP_EQ ] | ||
} | ||
]; | ||
} | ||
|
||
/** | ||
* The table associated with the model. | ||
* @return {String} | ||
*/ | ||
public getTable() { | ||
return "blocks"; | ||
} | ||
|
||
/** | ||
* The read-only structure with query-formatting columns. | ||
* @return {Object} | ||
*/ | ||
public getColumnSet() { | ||
return this.createColumnSet(this.columnsDescriptor.map(col => { | ||
const colDef: any = { | ||
name : col.name | ||
}; | ||
["prop", "init", "def"].forEach(prop => { | ||
if(col.hasOwnProperty(prop)) { | ||
colDef[prop] = col[prop]; | ||
} | ||
}); | ||
return colDef; | ||
})); | ||
} | ||
|
||
public getName(): string { | ||
return "Block"; | ||
} | ||
|
||
public getSearchableFields(): Database.SearchableField[] { | ||
return this.columnsDescriptor.map(col => { | ||
return { | ||
fieldName: col.prop || col.name, | ||
supportedOperators: col.supportedOperators | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export * from "./manager"; | ||
export * from "./database-service-factory"; | ||
export * from "./wallet-manager"; | ||
export * from "./repositories/delegates"; | ||
export * from "./repositories/wallets"; | ||
export * from "./repositories/delegates-business-repository"; | ||
export * from "./repositories/wallets-business-repository"; | ||
export * from "./plugin"; |
33 changes: 33 additions & 0 deletions
33
packages/core-database/src/repositories/blocks-business-repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Database } from "@arkecosystem/core-interfaces"; | ||
import { SearchParameterConverter } from "./utils/search-parameter-converter"; | ||
|
||
export class BlocksBusinessRepository implements Database.IBlocksBusinessRepository { | ||
|
||
constructor(private databaseServiceProvider: () => Database.IDatabaseService) { | ||
} | ||
|
||
public async findAll(params: any) { | ||
const blocksRepository = this.databaseServiceProvider().connection.blocksRepository; | ||
const searchParameters = new SearchParameterConverter(blocksRepository.getModel()).convert(params); | ||
return await blocksRepository.search(searchParameters); | ||
} | ||
|
||
public async findAllByGenerator(generatorPublicKey: string, paginate: any) { | ||
const params = { ...{ generatorPublicKey }, ...paginate }; | ||
return await this.findAll(params); | ||
} | ||
|
||
public async findByHeight(height: number) { | ||
const params = { ...{ height } }; | ||
return await this.findAll(params); | ||
} | ||
|
||
public async findById(id: string) { | ||
return await this.databaseServiceProvider().connection.blocksRepository.findById(id); | ||
} | ||
|
||
public async search(params: any) { | ||
return await this.findAll(params); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/core-database/src/repositories/transactions-business-repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Database } from "@arkecosystem/core-interfaces"; | ||
|
||
export class TransactionsBusinessRepository implements Database.ITransactionsBusinessRepository { | ||
|
||
constructor(private databaseServiceProvider: () => Database.IDatabaseService) { | ||
} | ||
|
||
public allVotesBySender(senderPublicKey: any, parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findAll(params: any, sequenceOrder: "asc" | "desc"): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findAllByBlock(blockId: any, parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findAllByRecipient(recipientId: any, parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findAllBySender(senderPublicKey: any, parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findAllByType(type: any, parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findAllByWallet(wallet: any, parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findAllLegacy(parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findById(id: string): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public findByTypeAndId(type: any, id: string): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public getFeeStatistics(): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
public search(parameters: any): Promise<any> { | ||
return undefined; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.