2014-09-04 03:32:38 -07:00
|
|
|
package consensus
|
|
|
|
|
|
|
|
import (
|
2014-09-07 02:21:25 -07:00
|
|
|
. "github.com/tendermint/tendermint/blocks"
|
2014-09-04 03:32:38 -07:00
|
|
|
db_ "github.com/tendermint/tendermint/db"
|
2014-10-16 16:00:48 -07:00
|
|
|
"github.com/tendermint/tendermint/state"
|
2014-09-04 03:32:38 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
type PrivValidator struct {
|
2014-10-20 19:02:10 -07:00
|
|
|
db db_.DB
|
2014-10-24 14:37:12 -07:00
|
|
|
state.PrivAccount
|
2014-10-20 19:02:10 -07:00
|
|
|
}
|
|
|
|
|
2014-10-24 14:37:12 -07:00
|
|
|
func NewPrivValidator(db db_.DB, priv *state.PrivAccount) *PrivValidator {
|
|
|
|
return &PrivValidator{db, *priv}
|
2014-09-04 03:32:38 -07:00
|
|
|
}
|
|
|
|
|
2014-10-07 23:11:04 -07:00
|
|
|
// Double signing results in a panic.
|
|
|
|
func (pv *PrivValidator) Sign(o Signable) {
|
|
|
|
switch o.(type) {
|
|
|
|
case *Proposal:
|
2014-10-18 01:42:33 -07:00
|
|
|
//TODO: prevent double signing && test.
|
2014-10-07 23:11:04 -07:00
|
|
|
pv.PrivAccount.Sign(o.(*Proposal))
|
|
|
|
case *Vote:
|
2014-10-18 01:42:33 -07:00
|
|
|
//TODO: prevent double signing && test.
|
2014-10-07 23:11:04 -07:00
|
|
|
pv.PrivAccount.Sign(o.(*Vote))
|
|
|
|
}
|
2014-09-04 03:32:38 -07:00
|
|
|
}
|