diff --git a/metadapta.go b/metadapta.go index 41ce59d..8250478 100644 --- a/metadapta.go +++ b/metadapta.go @@ -66,18 +66,21 @@ func (this *a) RemoteAddr() net.Addr { func (this *a) OpenTrans() (Trans, error) { this.transLock.Lock() defer this.transLock.Unlock() + if this.transID == int64Max { + return nil, fmt.Errorf("could not open transaction: %w", ErrIntegerOverflow) + } id := this.transID - this.transID ++ trans := &transA { parent: this, id: id, incoming: usync.NewGate[incomingMessage](), } this.transMap[id] = trans - if this.transID == int64Max { - return nil, fmt.Errorf("could not open transaction: %w", ErrIntegerOverflow) + if this.party == ClientSide { + this.transID ++ + } else { + this.transID -- } - this.transID ++ return trans, nil }