Skip to content

Commit

Permalink
use atomic pointer for fee recipient
Browse files Browse the repository at this point in the history
  • Loading branch information
bharath-123 committed Dec 3, 2024
1 parent 5c84a92 commit 328c629
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions grpc/shared/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ type SharedServiceContainer struct {
// auctioneer address is a bech32m address
auctioneerAddress atomic.Pointer[string]

// TODO: bharath - we could make this an atomic pointer???
nextFeeRecipient common.Address // Fee recipient for the next block
nextFeeRecipient atomic.Pointer[common.Address] // Fee recipient for the next block
}

func NewSharedServiceContainer(eth *eth.Ethereum) (*SharedServiceContainer, error) {
Expand Down Expand Up @@ -123,10 +122,10 @@ func NewSharedServiceContainer(eth *eth.Ethereum) (*SharedServiceContainer, erro
bc: bc,
bridgeAddresses: bridgeAddresses,
bridgeAllowedAssets: bridgeAllowedAssets,
nextFeeRecipient: nextFeeRecipient,
}

sharedServiceContainer.SetAuctioneerAddress(auctioneerAddress)
sharedServiceContainer.SetNextFeeRecipient(nextFeeRecipient)

return sharedServiceContainer, nil
}
Expand Down Expand Up @@ -168,12 +167,12 @@ func (s *SharedServiceContainer) BlockExecutionLock() *sync.Mutex {
}

func (s *SharedServiceContainer) NextFeeRecipient() common.Address {
return s.nextFeeRecipient
return *s.nextFeeRecipient.Load()
}

// assumes that the block execution lock is being held
func (s *SharedServiceContainer) SetNextFeeRecipient(nextFeeRecipient common.Address) {
s.nextFeeRecipient = nextFeeRecipient
s.nextFeeRecipient.Store(&nextFeeRecipient)
}

func (s *SharedServiceContainer) BridgeAddresses() map[string]*params.AstriaBridgeAddressConfig {
Expand Down

0 comments on commit 328c629

Please sign in to comment.