-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
762 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package beaconhttp | ||
|
||
import ( | ||
"encoding/json" | ||
"strconv" | ||
) | ||
|
||
type IntStr int | ||
|
||
func (i IntStr) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(strconv.FormatInt(int64(i), 10)) | ||
} | ||
|
||
func (i *IntStr) UnmarshalJSON(b []byte) error { | ||
// Try string first | ||
var s string | ||
if err := json.Unmarshal(b, &s); err == nil { | ||
value, err := strconv.ParseInt(s, 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
*i = IntStr(value) | ||
return nil | ||
} | ||
|
||
// Fallback to number | ||
return json.Unmarshal(b, (*int)(i)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package building | ||
|
||
import ( | ||
"github.com/ledgerwatch/erigon-lib/common" | ||
"github.com/ledgerwatch/erigon/cl/beacon/beaconhttp" | ||
) | ||
|
||
type BeaconCommitteeSubscription struct { | ||
ValidatorIndex int `json:"validator_index,string"` | ||
CommitteeIndex int `json:"committee_index,string"` | ||
CommitteesAtSlot int `json:"committees_at_slot,string"` | ||
Slot int `json:"slot,string"` | ||
IsAggregator bool `json:"is_aggregator"` | ||
} | ||
|
||
type SyncCommitteeSubscription struct { | ||
ValidatorIndex int `json:"validator_index,string"` | ||
SyncCommitteeIndices []beaconhttp.IntStr `json:"sync_committee_indices"` | ||
UntilEpoch int `json:"until_epoch,string"` | ||
} | ||
|
||
type PrepareBeaconProposer struct { | ||
ValidatorIndex int `json:"validator_index,string"` | ||
FeeRecipient common.Address `json:"fee_recipient"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package building | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/ledgerwatch/erigon-lib/common" | ||
) | ||
|
||
type State struct { | ||
feeRecipients map[int]common.Address | ||
|
||
mu sync.RWMutex | ||
} | ||
|
||
func NewState() *State { | ||
return &State{ | ||
feeRecipients: map[int]common.Address{}, | ||
} | ||
} | ||
|
||
func (s *State) SetFeeRecipient(idx int, address common.Address) { | ||
s.mu.Lock() | ||
defer s.mu.Unlock() | ||
s.feeRecipients[idx] = address | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.