call verify separatly as multithreaded version

This commit is contained in:
einhornimmond 2026-02-14 17:23:07 +01:00
parent 4dde30ea4b
commit 521e678e1f
3 changed files with 14 additions and 10 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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,