watchtower/wtdb: create embedded ClientSessionBody

This commit splits out the portions of the ClientSession into an
embedded ClientSessionBody, since these fields will be serialized
together on-disk.
This commit is contained in:
Conner Fromknecht committed 2019-05-23 20:47:49 -07:00
1 parent 5ad9530502
commit 1db9bf2fd4
6 files changed
+59 -37

No files matched your search

+6 -5
View File
@@ -417,14 +417,15 @@ func (n *sessionNegotiator) tryAddress(privKey *btcec.PrivateKey,
privKey.PubKey(),
)
clientSession := &wtdb.ClientSession{
TowerID: tower.ID,
ClientSessionBody: wtdb.ClientSessionBody{
TowerID: tower.ID,
KeyIndex: keyIndex,
Policy: n.cfg.Policy,
RewardPkScript: rewardPkScript,
},
Tower: tower,
KeyIndex: keyIndex,
SessionPrivKey: privKey,
ID: sessionID,
Policy: n.cfg.Policy,
SeqNum: 0,
RewardPkScript: rewardPkScript,
}
err = n.cfg.DB.CreateClientSession(clientSession)