From 058ecc5cf4e0fc39174529f0fae28c8078ffe64c Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Mon, 10 Feb 2025 03:13:39 -0600 Subject: [PATCH] parallelize commit path --- .../intrinsics/token/token_execution_engine.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/node/execution/intrinsics/token/token_execution_engine.go b/node/execution/intrinsics/token/token_execution_engine.go index 6d40a96..fcb6638 100644 --- a/node/execution/intrinsics/token/token_execution_engine.go +++ b/node/execution/intrinsics/token/token_execution_engine.go @@ -447,7 +447,7 @@ var _ execution.ExecutionEngine = (*TokenExecutionEngine)(nil) func (e *TokenExecutionEngine) addBatchToHypergraph(batchKey [][]byte, batchValue [][]byte) { var wg sync.WaitGroup throttle := make(chan struct{}, runtime.NumCPU()) - batchCompressed := make([][]hypergraph.Encrypted, len(batchKey)) + batchCompressed := make([]hypergraph.Vertex, len(batchKey)) for i, chunk := range batchValue { throttle <- struct{}{} wg.Add(1) @@ -470,18 +470,19 @@ func (e *TokenExecutionEngine) addBatchToHypergraph(batchKey [][]byte, batchValu "encrypted coin", zap.String("address", hex.EncodeToString(batchKey[i])), ) - batchCompressed[i] = compressed + batchCompressed[i] = hypergraph.NewVertex( + [32]byte(application.TOKEN_ADDRESS), + [32]byte(batchKey[i]), + compressed, + ) + batchCompressed[i].Commit() }(chunk, i) } wg.Wait() for i := range batchKey { if err := e.hypergraph.AddVertex( - hypergraph.NewVertex( - [32]byte(application.TOKEN_ADDRESS), - [32]byte(batchKey[i]), - batchCompressed[i], - ), + batchCompressed[i], ); err != nil { panic(err) }