Skip to content

Commit d149265

Browse files
authoredDec 13, 2018
Merge pull request #108 from republicprotocol/develop
Hotfix for order confirmed but not settled
2 parents 4f87803 + 3a34f48 commit d149265

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed
 

‎cmd/darknode/darknode.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ func main() {
290290
// Prune the database every hour and update the network with the
291291
// darknode address
292292
for {
293-
time.Sleep(time.Hour)
293+
sleepTime := 50 + rand.Intn(20)
294+
time.Sleep(time.Duration(sleepTime) * time.Minute)
295+
294296
if err := pingNetwork(swarmer); err != nil {
295297
log.Printf("[error] (prune) cannot ping network: %v", err)
296298
continue

‎crypto/keystore.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func RandomKeystore() (Keystore, error) {
6060

6161
// NewKeystore returns a new Keystore that stores an EcdsaKey and an RsaKey and
6262
// has a randomly generated UUID.
63-
func (keystore *Keystore) NewKeystore(ecdsaKey EcdsaKey, rsaKey RsaKey) Keystore {
63+
func NewKeystore(ecdsaKey EcdsaKey, rsaKey RsaKey) Keystore {
6464
return Keystore{
6565
ID: uuid.NewRandom(),
6666
Version: "3",

‎ome/confirmer.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type confirmer struct {
4444
// NewConfirmer returns a Confirmer that submits Computations to the
4545
// Orderbook for confirmation. It polls the Orderbook on an interval
4646
// and checks for consensus on confirmations by waiting until a submitted
47-
// Computation has been confirmed has the confirmation has passed the block
47+
// Computation has been confirmed and the confirmation has passed the block
4848
// depth limit.
4949
func NewConfirmer(computationStore ComputationStorer, fragmentStore OrderFragmentStorer, contract ContractBinder, orderbookPollInterval time.Duration, orderbookBlockDepth uint) Confirmer {
5050
return &confirmer{
@@ -84,35 +84,35 @@ func (confirmer *confirmer) Confirm(done <-chan struct{}, coms <-chan Computatio
8484
return
8585
}
8686

87-
go func() {
88-
89-
// Wait for the confirmation of these orders to pass the depth
90-
// limit
87+
// Wait for the confirmation of these orders to pass the depth
88+
// limit
89+
func(com Computation) {
9190
confirmer.confirmingMu.Lock()
91+
defer confirmer.confirmingMu.Unlock()
92+
9293
// Check that these orders have not already been confirmed
9394
if _, ok := confirmer.confirmed[com.Buy.OrderID]; ok {
94-
confirmer.confirmingMu.Unlock()
9595
return
9696
}
9797
if _, ok := confirmer.confirmed[com.Sell.OrderID]; ok {
98-
confirmer.confirmingMu.Unlock()
9998
return
10099
}
101100

102101
confirmer.confirmingBuyOrders[com.Buy.OrderID] = time.Now()
103102
confirmer.confirmingSellOrders[com.Sell.OrderID] = time.Now()
104-
confirmer.confirmingMu.Unlock()
105103

106104
// Confirm Computations on the blockchain and register them for
107105
// observation (we need to wait for finality)
108-
if err := confirmer.beginConfirmation(com); err != nil {
109-
// An error in confirmation should not stop the
110-
// Confirmer from monitoring the Computation for
111-
// confirmation (another node might have succeeded), so
112-
// we pass through
113-
logger.Error(err.Error())
114-
}
115-
}()
106+
go func() {
107+
if err := confirmer.beginConfirmation(com); err != nil {
108+
// An error in confirmation should not stop the
109+
// Confirmer from monitoring the Computation for
110+
// confirmation (another node might have succeeded), so
111+
// we pass through
112+
logger.Error(err.Error())
113+
}
114+
}()
115+
}(com)
116116
}
117117
}
118118
}()

0 commit comments

Comments
 (0)
Please sign in to comment.