mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-03-12 23:18:36 +00:00
Merge pull request #3831 from nspcc-dev/pretty-log
Improve errors reporting
This commit is contained in:
commit
e63cbe7c82
4 changed files with 22 additions and 8 deletions
|
@ -257,7 +257,7 @@ func uploadBlocksAndIndexFiles(ctx *cli.Context, p poolWrapper, rpc *rpcclient.C
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to upload index file: %w", err)
|
||||
}
|
||||
fmt.Println("Successfully uploaded index file ", indexFileStart/indexFileSize)
|
||||
fmt.Fprintln(ctx.App.Writer, "Successfully uploaded index file ", indexFileStart/indexFileSize)
|
||||
}
|
||||
clear(buf)
|
||||
}
|
||||
|
|
|
@ -2849,7 +2849,7 @@ func (bc *Blockchain) PoolTxWithData(t *transaction.Transaction, data any, mp *m
|
|||
if verificationFunction != nil {
|
||||
err := verificationFunction(t, data)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("data verification failed: %w", err)
|
||||
}
|
||||
}
|
||||
return bc.verifyAndPoolTx(t, mp, feer, data)
|
||||
|
|
|
@ -1325,7 +1325,11 @@ func (s *Server) RelayP2PNotaryRequest(r *payload.P2PNotaryRequest) error {
|
|||
|
||||
// verifyAndPoolNotaryRequest verifies NotaryRequest payload and adds it to the payload mempool.
|
||||
func (s *Server) verifyAndPoolNotaryRequest(r *payload.P2PNotaryRequest) error {
|
||||
return s.chain.PoolTxWithData(r.FallbackTransaction, r, s.notaryRequestPool, s.notaryFeer, s.verifyNotaryRequest)
|
||||
err := s.chain.PoolTxWithData(r.FallbackTransaction, r, s.notaryRequestPool, s.notaryFeer, s.verifyNotaryRequest)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add fallback transaction to the notary pool: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// verifyNotaryRequest is a function for state-dependant P2PNotaryRequest payload verification which is executed before ordinary blockchain's verification.
|
||||
|
|
|
@ -333,7 +333,7 @@ func (n *Notary) OnNewRequest(payload *payload.P2PNotaryRequest) {
|
|||
}
|
||||
if r.isMainCompleted() && r.minNotValidBefore > n.Config.Chain.BlockHeight() {
|
||||
if err := n.finalize(acc, r.main, payload.MainTransaction.Hash()); err != nil {
|
||||
n.Config.Log.Error("failed to finalize main transaction",
|
||||
n.Config.Log.Error("failed to finalize main transaction, waiting for the next block to retry",
|
||||
zap.String("hash", r.main.Hash().StringLE()),
|
||||
zap.Error(err))
|
||||
}
|
||||
|
@ -381,7 +381,9 @@ func (n *Notary) PostPersist() {
|
|||
for h, r := range n.requests {
|
||||
if !r.isSent && r.isMainCompleted() && r.minNotValidBefore > currHeight {
|
||||
if err := n.finalize(acc, r.main, h); err != nil {
|
||||
n.Config.Log.Error("failed to finalize main transaction", zap.Error(err))
|
||||
n.Config.Log.Error("failed to finalize main transaction after PostPersist, waiting for the next block to retry",
|
||||
zap.String("hash", r.main.Hash().StringLE()),
|
||||
zap.Error(err))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -389,7 +391,10 @@ func (n *Notary) PostPersist() {
|
|||
for _, fb := range r.fallbacks {
|
||||
if nvb := fb.GetAttributes(transaction.NotValidBeforeT)[0].Value.(*transaction.NotValidBefore).Height; nvb <= currHeight {
|
||||
// Ignore the error, wait for the next block to resend them
|
||||
_ = n.finalize(acc, fb, h)
|
||||
err := n.finalize(acc, fb, h)
|
||||
n.Config.Log.Error("failed to finalize fallback transaction, waiting for the next block to retry",
|
||||
zap.String("hash", fb.Hash().StringLE()),
|
||||
zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,7 +418,10 @@ func (n *Notary) finalize(acc *wallet.Account, tx *transaction.Transaction, h ut
|
|||
return fmt.Errorf("failed to update completed transaction's size: %w", err)
|
||||
}
|
||||
|
||||
n.pushNewTx(newTx, h)
|
||||
err = n.pushNewTx(newTx, h)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to enqueue completed transaction: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -423,11 +431,13 @@ type txHashPair struct {
|
|||
mainHash util.Uint256
|
||||
}
|
||||
|
||||
func (n *Notary) pushNewTx(tx *transaction.Transaction, h util.Uint256) {
|
||||
func (n *Notary) pushNewTx(tx *transaction.Transaction, h util.Uint256) error {
|
||||
select {
|
||||
case n.newTxs <- txHashPair{tx, h}:
|
||||
default:
|
||||
return errors.New("transaction queue is full")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *Notary) newTxCallbackLoop() {
|
||||
|
|
Loading…
Add table
Reference in a new issue