Skip to content

Commit

Permalink
tss/party: fix WaitingFor() call on non-started Party causes panic, a…
Browse files Browse the repository at this point in the history
…dd Running()

fixes #82
  • Loading branch information
notatestuser committed Dec 27, 2019
1 parent 129ebae commit 4fcd04b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tss/party.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Party interface {
UpdateFromBytes(wireBytes []byte, from *PartyID, isBroadcast bool) (ok bool, err *Error)
// You may use this entry point to update a party's state when running locally or in tests
Update(msg ParsedMessage) (ok bool, err *Error)
Running() bool
WaitingFor() []*PartyID
ValidateMessage(msg ParsedMessage) (bool, *Error)
StoreMessage(msg ParsedMessage) (bool, *Error)
Expand All @@ -43,13 +44,23 @@ type BaseParty struct {
FirstRound Round
}

func (p *BaseParty) Running() bool {
return p.rnd != nil
}

func (p *BaseParty) WaitingFor() []*PartyID {
p.lock()
defer p.unlock()
if p.rnd == nil {
return []*PartyID{}
}
return p.rnd.WaitingFor()
}

func (p *BaseParty) WrapError(err error, culprits ...*PartyID) *Error {
if p.rnd == nil {
return NewError(err, "", -1, nil, culprits...)
}
return p.rnd.WrapError(err, culprits...)
}

Expand Down

0 comments on commit 4fcd04b

Please sign in to comment.