@@ -2,12 +2,10 @@ package processor
2
2
3
3
import (
4
4
"encoding/hex"
5
- "time"
6
5
7
6
"github.com/prometheus/client_golang/prometheus"
8
7
"github.com/prometheus/client_golang/prometheus/promauto"
9
8
10
- ethcommon "github.com/ethereum/go-ethereum/common"
11
9
"github.com/ethereum/go-ethereum/crypto"
12
10
"google.golang.org/protobuf/proto"
13
11
@@ -50,20 +48,19 @@ func (p *Processor) broadcastSignature(
50
48
// Store our VAA in case we're going to submit it to Solana
51
49
hash := hex .EncodeToString (digest .Bytes ())
52
50
53
- if p .state .signatures [hash ] == nil {
54
- p .state .signatures [hash ] = & state {
55
- firstObserved : time .Now (),
56
- nextRetry : time .Now ().Add (nextRetryDuration (0 )),
57
- signatures : map [ethcommon.Address ][]byte {},
58
- source : "loopback" ,
59
- }
51
+ obsState , created := p .state .getOrCreateState (hash )
52
+ obsState .lock .Lock ()
53
+ defer obsState .lock .Unlock ()
54
+
55
+ if created {
56
+ obsState .source = "loopback"
60
57
}
61
58
62
- p . state . signatures [ hash ] .ourObservation = o
63
- p . state . signatures [ hash ] .ourMsg = msg
64
- p . state . signatures [ hash ] .txHash = txhash
65
- p . state . signatures [ hash ] .source = o .GetEmitterChain ().String ()
66
- p . state . signatures [ hash ]. gs = p .gs // guaranteed to match ourObservation - there's no concurrent access to p.gs
59
+ obsState .ourObservation = o
60
+ obsState .ourMsg = msg
61
+ obsState .txHash = txhash
62
+ obsState .source = o .GetEmitterChain ().String ()
63
+ obsState . gs = p .gst . Get ()
67
64
68
65
// Fast path for our own signature
69
66
// send to obsvC directly if there is capacity, otherwise do it in a go routine.
0 commit comments