Skip to content

Commit

Permalink
Node: Multithreaded processor
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley committed May 14, 2024
1 parent 6294969 commit 58e5873
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 252 deletions.
25 changes: 11 additions & 14 deletions node/pkg/processor/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package processor

import (
"encoding/hex"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"google.golang.org/protobuf/proto"

Expand Down Expand Up @@ -50,20 +48,19 @@ func (p *Processor) broadcastSignature(
// Store our VAA in case we're going to submit it to Solana
hash := hex.EncodeToString(digest.Bytes())

if p.state.signatures[hash] == nil {
p.state.signatures[hash] = &state{
firstObserved: time.Now(),
nextRetry: time.Now().Add(nextRetryDuration(0)),
signatures: map[ethcommon.Address][]byte{},
source: "loopback",
}
obsState, created := p.state.getOrCreateState(hash)
obsState.lock.Lock()
defer obsState.lock.Unlock()

if created {
obsState.source = "loopback"
}

p.state.signatures[hash].ourObservation = o
p.state.signatures[hash].ourMsg = msg
p.state.signatures[hash].txHash = txhash
p.state.signatures[hash].source = o.GetEmitterChain().String()
p.state.signatures[hash].gs = p.gs // guaranteed to match ourObservation - there's no concurrent access to p.gs
obsState.ourObservation = o
obsState.ourMsg = msg
obsState.txHash = txhash
obsState.source = o.GetEmitterChain().String()
obsState.gs = p.gst.Get()

// Fast path for our own signature
// send to obsvC directly if there is capacity, otherwise do it in a go routine.
Expand Down
Loading

0 comments on commit 58e5873

Please sign in to comment.