consensus: replace SugaredLogger with Logger
SugaredLogger was used to make output look more similar to logrus. This is no longer needed.
This commit is contained in:
parent
9b8b77c9ea
commit
dc65684708
1 changed files with 10 additions and 8 deletions
|
@ -46,7 +46,7 @@ type Service interface {
|
|||
type service struct {
|
||||
Config
|
||||
|
||||
log *zap.SugaredLogger
|
||||
log *zap.Logger
|
||||
// cache is a fifo cache which stores recent payloads.
|
||||
cache *relayCache
|
||||
// txx is a fifo cache which stores miner transactions.
|
||||
|
@ -92,7 +92,7 @@ func NewService(cfg Config) (Service, error) {
|
|||
srv := &service{
|
||||
Config: cfg,
|
||||
|
||||
log: cfg.Logger.Sugar(),
|
||||
log: cfg.Logger,
|
||||
cache: newFIFOCache(cacheMaxCapacity),
|
||||
txx: newFIFOCache(cacheMaxCapacity),
|
||||
messages: make(chan Payload, 100),
|
||||
|
@ -107,7 +107,7 @@ func NewService(cfg Config) (Service, error) {
|
|||
priv, pub := getKeyPair(cfg.Wallet)
|
||||
|
||||
srv.dbft = dbft.New(
|
||||
dbft.WithLogger(srv.log.Desugar()),
|
||||
dbft.WithLogger(srv.log),
|
||||
dbft.WithSecondsPerBlock(cfg.TimePerBlock),
|
||||
dbft.WithKeyPair(priv, pub),
|
||||
dbft.WithTxPerBlock(10000),
|
||||
|
@ -154,10 +154,12 @@ func (s *service) eventLoop() {
|
|||
for {
|
||||
select {
|
||||
case hv := <-s.dbft.Timer.C():
|
||||
s.log.Debugf("timer fired (%d,%d)", hv.Height, hv.View)
|
||||
s.log.Debug("timer fired",
|
||||
zap.Uint32("height", hv.Height),
|
||||
zap.Uint("view", uint(hv.View)))
|
||||
s.dbft.OnTimeout(hv)
|
||||
case msg := <-s.messages:
|
||||
s.log.Debugf("received message from %d", msg.validatorIndex)
|
||||
s.log.Debug("received message", zap.Uint16("from", msg.validatorIndex))
|
||||
s.dbft.OnReceive(&msg)
|
||||
case tx := <-s.transactions:
|
||||
s.dbft.OnTransaction(tx)
|
||||
|
@ -240,7 +242,7 @@ func (s *service) broadcast(p payload.ConsensusPayload) {
|
|||
}
|
||||
|
||||
if err := p.(*Payload).Sign(s.dbft.Priv.(*privateKey)); err != nil {
|
||||
s.log.Warnf("can't sign consensus payload: %v", err)
|
||||
s.log.Warn("can't sign consensus payload", zap.Error(err))
|
||||
}
|
||||
|
||||
s.cache.Add(p)
|
||||
|
@ -279,7 +281,7 @@ func (s *service) processBlock(b block.Block) {
|
|||
bb.Script = *(s.getBlockWitness(bb))
|
||||
|
||||
if err := s.Chain.AddBlock(bb); err != nil {
|
||||
s.log.Warnf("error on add block: %v", err)
|
||||
s.log.Warn("error on add block", zap.Error(err))
|
||||
} else {
|
||||
s.Config.RelayBlock(bb)
|
||||
}
|
||||
|
@ -299,7 +301,7 @@ func (s *service) getBlockWitness(b *core.Block) *transaction.Witness {
|
|||
m := s.dbft.Context.M()
|
||||
verif, err := smartcontract.CreateMultiSigRedeemScript(m, pubs)
|
||||
if err != nil {
|
||||
s.log.Warnf("can't create multisig redeem script: %v", err)
|
||||
s.log.Warn("can't create multisig redeem script", zap.Error(err))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue