mirror of
https://github.com/IT4Change/gradido.git
synced 2026-04-06 01:25:28 +00:00
call verify separatly as multithreaded version
This commit is contained in:
parent
4dde30ea4b
commit
521e678e1f
@ -4,10 +4,8 @@ import {
|
||||
GradidoTransaction,
|
||||
HieroAccountId,
|
||||
InMemoryBlockchain,
|
||||
InMemoryBlockchainProvider,
|
||||
LedgerAnchor,
|
||||
Profiler,
|
||||
TransactionEntry,
|
||||
} from 'gradido-blockchain-js'
|
||||
import { NotEnoughGradidoBalanceError } from './errors'
|
||||
|
||||
@ -21,10 +19,9 @@ export function addToBlockchain(
|
||||
ledgerAnchor: LedgerAnchor,
|
||||
accountBalances: AccountBalances,
|
||||
): boolean {
|
||||
|
||||
try {
|
||||
timeUsed.reset()
|
||||
const result = blockchain.createAndAddConfirmedTransactionExtern(
|
||||
const result = blockchain.createAndAddConfirmedTransactionExternFast(
|
||||
transaction,
|
||||
ledgerAnchor,
|
||||
accountBalances,
|
||||
|
||||
@ -2,7 +2,8 @@ import { onShutdown } from '../../../../shared/src/helper/onShutdown'
|
||||
import { exportAllCommunities } from './binaryExport'
|
||||
import { bootstrap } from './bootstrap'
|
||||
import { syncDbWithBlockchainContext } from './interaction/syncDbWithBlockchain/syncDbWithBlockchain.context'
|
||||
// import { hello } from '../../../zig/hello.zig'
|
||||
import { Filter, Profiler, ThreadingPolicy_Half, verifySignatures } from 'gradido-blockchain-js'
|
||||
// import { hello } from '../../../zig/hello.zig'
|
||||
|
||||
const BATCH_SIZE = 1000
|
||||
|
||||
@ -26,6 +27,17 @@ async function main() {
|
||||
//context.logBlogchain(v.parse(uuidv4Schema, 'e70da33e-5976-4767-bade-aa4e4fa1c01a'))
|
||||
}
|
||||
|
||||
const timeUsed = new Profiler()
|
||||
// bulk verify transaction signatures
|
||||
for (const communityContext of context.communities.values()) {
|
||||
// verifySignatures(Filter.ALL_TRANSACTIONS, ThreadingPolicy_Half)
|
||||
const result = verifySignatures(Filter.ALL_TRANSACTIONS, communityContext.communityId, ThreadingPolicy_Half)
|
||||
if(!result.isEmpty()){
|
||||
throw new Error(`Verification of signatures failed for community ${communityContext.communityId}`)
|
||||
}
|
||||
}
|
||||
context.logger.info(`verified in ${timeUsed.string()}`)
|
||||
|
||||
// write as binary file for GradidoNode
|
||||
exportAllCommunities(context, BATCH_SIZE)
|
||||
|
||||
|
||||
@ -165,9 +165,6 @@ export class RemoteTransactionsSyncRole extends AbstractSyncRole<TransactionDb>
|
||||
recipientCommunityContext.communityId
|
||||
)
|
||||
const outboundTransaction = transactionBuilder.buildOutbound()
|
||||
console.log(ledgerAnchor.toJson(true))
|
||||
console.log(outboundTransaction.toJson(true))
|
||||
console.log("outbound coin color: %d", outboundTransaction.getTransactionBody()?.getTransferAmount().getCoinCommunityIdIndex())
|
||||
|
||||
try {
|
||||
addToBlockchain(
|
||||
@ -184,8 +181,6 @@ export class RemoteTransactionsSyncRole extends AbstractSyncRole<TransactionDb>
|
||||
}
|
||||
transactionBuilder.setParentLedgerAnchor(ledgerAnchor)
|
||||
const inboundTransaction = transactionBuilder.buildInbound()
|
||||
console.log(inboundTransaction.toJson(true))
|
||||
console.log("inbound coin color: %d", inboundTransaction.getTransactionBody()?.getTransferAmount().getCoinCommunityIdIndex())
|
||||
try {
|
||||
addToBlockchain(
|
||||
inboundTransaction,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user