wtwire/create_session: add RewardBase field to CreateSession

This commit is contained in:
Conner Fromknecht 2019-01-31 18:16:04 -08:00
parent 26f4131102
commit 46a86a863a
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
2 changed files with 11 additions and 3 deletions

View File

@ -20,6 +20,11 @@ type CreateSession struct {
// for this session.
MaxUpdates uint16
// RewardBase is the fixed amount allocated to the tower when the
// policy's blob type specifies a reward for the tower. This is taken
// before adding the proportional reward.
RewardBase uint32
// RewardRate is the fraction of the total balance of the revoked
// commitment that the watchtower is entitled to. This value is
// expressed in millionths of the total balance.
@ -44,6 +49,7 @@ func (m *CreateSession) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&m.BlobType,
&m.MaxUpdates,
&m.RewardBase,
&m.RewardRate,
&m.SweepFeeRate,
)
@ -57,6 +63,7 @@ func (m *CreateSession) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
m.BlobType,
m.MaxUpdates,
m.RewardBase,
m.RewardRate,
m.SweepFeeRate,
)
@ -75,5 +82,5 @@ func (m *CreateSession) MsgType() MessageType {
//
// This is part of the wtwire.Message interface.
func (m *CreateSession) MaxPayloadLength(uint32) uint32 {
return 16
return 2 + 2 + 4 + 4 + 8 // 20
}

View File

@ -11,8 +11,9 @@ func MessageSummary(msg Message) string {
case *CreateSession:
return fmt.Sprintf("blob_type=%s, max_updates=%d "+
"reward_rate=%d sweep_fee_rate=%d", msg.BlobType,
msg.MaxUpdates, msg.RewardRate, msg.SweepFeeRate)
"reward_base=%d reward_rate=%d sweep_fee_rate=%d",
msg.BlobType, msg.MaxUpdates, msg.RewardBase,
msg.RewardRate, msg.SweepFeeRate)
case *CreateSessionReply:
return fmt.Sprintf("code=%d", msg.Code)