node/processor: Remove dead code
This commit is contained in:
parent
dcb720309b
commit
b780b3dab2
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
|
||||||
"github.com/certusone/wormhole/node/pkg/db"
|
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
@ -95,39 +94,6 @@ func (p *Processor) handleMessage(ctx context.Context, k *common.MessagePublicat
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore incoming observations when our database already has a quorum VAA for it.
|
|
||||||
// This can occur when we're receiving late observations due to node catchup, and
|
|
||||||
// processing those won't do us any good.
|
|
||||||
//
|
|
||||||
// Exception: if an observation is made within the settlement time (30s), we'll
|
|
||||||
// process it so other nodes won't consider it a miss.
|
|
||||||
|
|
||||||
if existing, err := p.getSignedVAA(*db.VaaIDFromVAA(&v.VAA)); err == nil {
|
|
||||||
if k.Timestamp.Sub(existing.Timestamp) > settlementTime {
|
|
||||||
p.logger.Info("ignoring observation since we already have a quorum VAA for it",
|
|
||||||
zap.Stringer("emitter_chain", k.EmitterChain),
|
|
||||||
zap.Stringer("emitter_address", k.EmitterAddress),
|
|
||||||
zap.String("emitter_address_b58", base58.Encode(k.EmitterAddress.Bytes())),
|
|
||||||
zap.Uint32("nonce", k.Nonce),
|
|
||||||
zap.Stringer("txhash", k.TxHash),
|
|
||||||
zap.String("txhash_b58", base58.Encode(k.TxHash.Bytes())),
|
|
||||||
zap.Time("timestamp", k.Timestamp),
|
|
||||||
zap.String("message_id", v.MessageID()),
|
|
||||||
zap.Duration("settlement_time", settlementTime),
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else if err != db.ErrVAANotFound {
|
|
||||||
p.logger.Error("failed to get VAA from db",
|
|
||||||
zap.Stringer("emitter_chain", k.EmitterChain),
|
|
||||||
zap.Stringer("emitter_address", k.EmitterAddress),
|
|
||||||
zap.Uint32("nonce", k.Nonce),
|
|
||||||
zap.Stringer("txhash", k.TxHash),
|
|
||||||
zap.Time("timestamp", k.Timestamp),
|
|
||||||
zap.Error(err),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate digest of the unsigned VAA.
|
// Generate digest of the unsigned VAA.
|
||||||
digest := v.SigningDigest()
|
digest := v.SigningDigest()
|
||||||
|
|
||||||
|
|
|
@ -327,32 +327,3 @@ func (p *Processor) haveSignedVAA(id db.VAAID) bool {
|
||||||
|
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Processor) getSignedVAA(id db.VAAID) (*vaa.VAA, error) {
|
|
||||||
|
|
||||||
if id.EmitterChain == vaa.ChainIDPythNet {
|
|
||||||
key := fmt.Sprintf("%v/%v", id.EmitterAddress, id.Sequence)
|
|
||||||
ret, exists := p.pythnetVaas[key]
|
|
||||||
if exists {
|
|
||||||
return ret.v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, db.ErrVAANotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.db == nil {
|
|
||||||
return nil, db.ErrVAANotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
vb, err := p.db.GetSignedVAABytes(id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
vaa, err := vaa.Unmarshal(vb)
|
|
||||||
if err != nil {
|
|
||||||
panic("failed to unmarshal VAA from db")
|
|
||||||
}
|
|
||||||
|
|
||||||
return vaa, err
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue