mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-23 04:50:59 +00:00
get_v1_beacon_pool_attestations() implementation.
This commit is contained in:
parent
7e4ff7a740
commit
9e7f8b37c7
@ -261,6 +261,33 @@ proc getAttestationsForSlot*(pool: AttestationPool, newBlockSlot: Slot):
|
|||||||
|
|
||||||
some(pool.candidates[candidateIdx.get()])
|
some(pool.candidates[candidateIdx.get()])
|
||||||
|
|
||||||
|
proc getAttestations*(pool: AttestationPool, slot: Option[Slot],
|
||||||
|
index: Option[CommitteeIndex]): seq[Attestation] =
|
||||||
|
var res: seq[Attestation]
|
||||||
|
for seenAttestations in pool.candidates.items():
|
||||||
|
for entry in seenAttestations.attestations.items():
|
||||||
|
let slotInclude =
|
||||||
|
if slot.isSome():
|
||||||
|
entry.data.slot == slot.get()
|
||||||
|
else:
|
||||||
|
true
|
||||||
|
|
||||||
|
let committeeInclude =
|
||||||
|
if index.isSome():
|
||||||
|
CommitteeIndex(entry.data.index) == index.get()
|
||||||
|
else:
|
||||||
|
true
|
||||||
|
|
||||||
|
if slotInclude or committeeInclude:
|
||||||
|
for validation in entry.validations.items():
|
||||||
|
let attestation = Attestation(
|
||||||
|
aggregation_bits: validation.aggregation_bits,
|
||||||
|
signature: validation.aggregate_signature,
|
||||||
|
data: entry.data
|
||||||
|
)
|
||||||
|
res.add(attestation)
|
||||||
|
res
|
||||||
|
|
||||||
proc getAttestationsForBlock*(pool: AttestationPool,
|
proc getAttestationsForBlock*(pool: AttestationPool,
|
||||||
state: BeaconState,
|
state: BeaconState,
|
||||||
cache: var StateCache): seq[Attestation] =
|
cache: var StateCache): seq[Attestation] =
|
||||||
|
@ -237,8 +237,30 @@ proc installBeaconApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
|
|||||||
blockId: string) -> seq[TrustedAttestation]:
|
blockId: string) -> seq[TrustedAttestation]:
|
||||||
return node.getBlockDataFromBlockId(blockId).data.message.body.attestations.asSeq
|
return node.getBlockDataFromBlockId(blockId).data.message.body.attestations.asSeq
|
||||||
|
|
||||||
rpcServer.rpc("get_v1_beacon_pool_attestations") do () -> JsonNode:
|
rpcServer.rpc("get_v1_beacon_pool_attestations") do (
|
||||||
unimplemented()
|
slot: Option[string], committee_index: Option[string]) -> seq[Attestation]:
|
||||||
|
|
||||||
|
let qslot =
|
||||||
|
if slot.isSome():
|
||||||
|
var tmp: uint64
|
||||||
|
let sslot = slot.get()
|
||||||
|
if parseBiggestUInt(sslot, tmp) != len(sslot):
|
||||||
|
raise newException(CatchableError, "Incorrect slot number")
|
||||||
|
some(Slot(tmp))
|
||||||
|
else:
|
||||||
|
none[Slot]()
|
||||||
|
|
||||||
|
let qindex =
|
||||||
|
if committee_index.isSome():
|
||||||
|
var tmp: uint64
|
||||||
|
let scommittee_index = committee_index.get()
|
||||||
|
if parseBiggestUInt(scommittee_index, tmp) != len(scommittee_index):
|
||||||
|
raise newException(CatchableError, "Incorrect committee_index number")
|
||||||
|
some(CommitteeIndex(tmp))
|
||||||
|
else:
|
||||||
|
none[CommitteeIndex]()
|
||||||
|
|
||||||
|
return node.attestationPool[].getAttestations(qslot, qindex)
|
||||||
|
|
||||||
rpcServer.rpc("post_v1_beacon_pool_attestations") do (
|
rpcServer.rpc("post_v1_beacon_pool_attestations") do (
|
||||||
attestation: Attestation) -> bool:
|
attestation: Attestation) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user