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:
6 files changed
+59
-37
No files matched your search
@@ -126,8 +126,7 @@ func (t *backupTask) inputs() map[wire.OutPoint]input.Input {
|
||||
// SessionInfo's policy. If no error is returned, the task has been bound to the
|
||||
// session and can be queued to upload to the tower. Otherwise, the bind failed
|
||||
// and should be rescheduled with a different session.
|
||||
func (t *backupTask) bindSession(session *wtdb.ClientSession) error {
|
||||
|
||||
func (t *backupTask) bindSession(session *wtdb.ClientSessionBody) error {
|
||||
// First we'll begin by deriving a weight estimate for the justice
|
||||
// transaction. The final weight can be different depending on whether
|
||||
// the watchtower is taking a reward.
|
||||
|
||||
@@ -69,7 +69,7 @@ type backupTaskTest struct {
|
||||
expSweepAmt int64
|
||||
expRewardAmt int64
|
||||
expRewardScript []byte
|
||||
session *wtdb.ClientSession
|
||||
session *wtdb.ClientSessionBody
|
||||
bindErr error
|
||||
expSweepScript []byte
|
||||
signer input.Signer
|
||||
@@ -205,7 +205,7 @@ func genTaskTest(
|
||||
expSweepAmt: expSweepAmt,
|
||||
expRewardAmt: expRewardAmt,
|
||||
expRewardScript: rewardScript,
|
||||
session: &wtdb.ClientSession{
|
||||
session: &wtdb.ClientSessionBody{
|
||||
Policy: wtpolicy.Policy{
|
||||
BlobType: blobType,
|
||||
SweepFeeRate: sweepFeeRate,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -215,7 +215,7 @@ func (q *sessionQueue) AcceptTask(task *backupTask) (reserveStatus, bool) {
|
||||
//
|
||||
// TODO(conner): queue backups and retry with different session params.
|
||||
case reserveAvailable:
|
||||
err := task.bindSession(q.cfg.ClientSession)
|
||||
err := task.bindSession(&q.cfg.ClientSession.ClientSessionBody)
|
||||
if err != nil {
|
||||
q.queueCond.L.Unlock()
|
||||
log.Debugf("SessionQueue %s rejected backup chanid=%s "+
|
||||
|
||||
Reference in new issue
Block a user