From 7bb5ac045e5e2f06bbae085114aeffc80af58de4 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Sat, 15 Aug 2015 00:33:52 +0200 Subject: [PATCH] xeth: added a transact mu Added a transact mutex. The transact mutex will fix an issue where transactions were created with the same nonce resulting in some transactions being dropped. This happened when two concurrent calls would call the `Transact` method (which is OK) which would both call `GetNonce`. While the managed is thread safe it does not help us in this case. --- xeth/xeth.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xeth/xeth.go b/xeth/xeth.go index 5a57608bc1..0ad0e507a2 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -89,8 +89,7 @@ type XEth struct { messagesMu sync.RWMutex messages map[int]*whisperFilter - // regmut sync.Mutex - // register map[string][]*interface{} // TODO improve return type + transactMu sync.Mutex agent *miner.RemoteAgent @@ -952,8 +951,9 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS } */ - // TODO: align default values to have the same type, e.g. not depend on - // common.Value conversions later on + self.transactMu.Lock() + defer self.transactMu.Unlock() + var nonce uint64 if len(nonceStr) != 0 { nonce = common.Big(nonceStr).Uint64()