forked from TrueCloudLab/neoneo-go
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 {
|
type service struct {
|
||||||
Config
|
Config
|
||||||
|
|
||||||
log *zap.SugaredLogger
|
log *zap.Logger
|
||||||
// cache is a fifo cache which stores recent payloads.
|
// cache is a fifo cache which stores recent payloads.
|
||||||
cache *relayCache
|
cache *relayCache
|
||||||
// txx is a fifo cache which stores miner transactions.
|
// txx is a fifo cache which stores miner transactions.
|
||||||
|
@ -92,7 +92,7 @@ func NewService(cfg Config) (Service, error) {
|
||||||
srv := &service{
|
srv := &service{
|
||||||
Config: cfg,
|
Config: cfg,
|
||||||
|
|
||||||
log: cfg.Logger.Sugar(),
|
log: cfg.Logger,
|
||||||
cache: newFIFOCache(cacheMaxCapacity),
|
cache: newFIFOCache(cacheMaxCapacity),
|
||||||
txx: newFIFOCache(cacheMaxCapacity),
|
txx: newFIFOCache(cacheMaxCapacity),
|
||||||
messages: make(chan Payload, 100),
|
messages: make(chan Payload, 100),
|
||||||
|
@ -107,7 +107,7 @@ func NewService(cfg Config) (Service, error) {
|
||||||
priv, pub := getKeyPair(cfg.Wallet)
|
priv, pub := getKeyPair(cfg.Wallet)
|
||||||
|
|
||||||
srv.dbft = dbft.New(
|
srv.dbft = dbft.New(
|
||||||
dbft.WithLogger(srv.log.Desugar()),
|
dbft.WithLogger(srv.log),
|
||||||
dbft.WithSecondsPerBlock(cfg.TimePerBlock),
|
dbft.WithSecondsPerBlock(cfg.TimePerBlock),
|
||||||
dbft.WithKeyPair(priv, pub),
|
dbft.WithKeyPair(priv, pub),
|
||||||
dbft.WithTxPerBlock(10000),
|
dbft.WithTxPerBlock(10000),
|
||||||
|
@ -154,10 +154,12 @@ func (s *service) eventLoop() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case hv := <-s.dbft.Timer.C():
|
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)
|
s.dbft.OnTimeout(hv)
|
||||||
case msg := <-s.messages:
|
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)
|
s.dbft.OnReceive(&msg)
|
||||||
case tx := <-s.transactions:
|
case tx := <-s.transactions:
|
||||||
s.dbft.OnTransaction(tx)
|
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 {
|
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)
|
s.cache.Add(p)
|
||||||
|
@ -279,7 +281,7 @@ func (s *service) processBlock(b block.Block) {
|
||||||
bb.Script = *(s.getBlockWitness(bb))
|
bb.Script = *(s.getBlockWitness(bb))
|
||||||
|
|
||||||
if err := s.Chain.AddBlock(bb); err != nil {
|
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 {
|
} else {
|
||||||
s.Config.RelayBlock(bb)
|
s.Config.RelayBlock(bb)
|
||||||
}
|
}
|
||||||
|
@ -299,7 +301,7 @@ func (s *service) getBlockWitness(b *core.Block) *transaction.Witness {
|
||||||
m := s.dbft.Context.M()
|
m := s.dbft.Context.M()
|
||||||
verif, err := smartcontract.CreateMultiSigRedeemScript(m, pubs)
|
verif, err := smartcontract.CreateMultiSigRedeemScript(m, pubs)
|
||||||
if err != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue