summaryrefslogtreecommitdiffhomepage
path: root/src/keypair.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-30 14:41:08 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-30 14:41:08 +0200
commitba3e486667987f16290ac85dc35b53cb9702d662 (patch)
tree2db62dcb54eb231f3673cfde54ace4dfaedb5f04 /src/keypair.go
parent7e185db1418635a28e5aacbd17b1f17b9ab89e35 (diff)
Completed initial version of outbound flow
Diffstat (limited to 'src/keypair.go')
-rw-r--r--src/keypair.go25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/keypair.go b/src/keypair.go
index 0b029ce..0e845f7 100644
--- a/src/keypair.go
+++ b/src/keypair.go
@@ -13,20 +13,27 @@ type KeyPair struct {
sendNonce uint64
isInitiator bool
created time.Time
+ id uint32
}
type KeyPairs struct {
- mutex sync.RWMutex
- current *KeyPair
- previous *KeyPair
- next *KeyPair // not yet "confirmed by transport"
- newKeyPair chan bool // signals when "current" has been updated
+ mutex sync.RWMutex
+ current *KeyPair
+ previous *KeyPair
+ next *KeyPair // not yet "confirmed by transport"
}
-func (kp *KeyPairs) Init() {
- kp.mutex.Lock()
- kp.newKeyPair = make(chan bool, 5)
- kp.mutex.Unlock()
+/* Called during recieving to confirm the handshake
+ * was completed correctly
+ */
+func (kp *KeyPairs) Used(key *KeyPair) {
+ if key == kp.next {
+ kp.mutex.Lock()
+ kp.previous = kp.current
+ kp.current = key
+ kp.next = nil
+ kp.mutex.Unlock()
+ }
}
func (kp *KeyPairs) Current() *KeyPair {