-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add draft implementation for ExecutionPayloadEnvelopesByRange
- Loading branch information
1 parent
c805fb2
commit b7dc4bf
Showing
9 changed files
with
575 additions
and
9 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
74 changes: 74 additions & 0 deletions
74
.../datastructures/networking/libp2p/rpc/ExecutionPayloadEnvelopesByRangeRequestMessage.java
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,74 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2022 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc; | ||
|
||
import tech.pegasys.teku.infrastructure.ssz.containers.Container2; | ||
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; | ||
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; | ||
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
|
||
public final class ExecutionPayloadEnvelopesByRangeRequestMessage | ||
extends Container2<ExecutionPayloadEnvelopesByRangeRequestMessage, SszUInt64, SszUInt64> | ||
implements RpcRequest { | ||
|
||
public static class ExecutionPayloadEnvelopesByRangeRequestMessageSchema | ||
extends ContainerSchema2< | ||
ExecutionPayloadEnvelopesByRangeRequestMessage, SszUInt64, SszUInt64> { | ||
|
||
public ExecutionPayloadEnvelopesByRangeRequestMessageSchema() { | ||
super( | ||
"ExecutionPayloadEnvelopesByRangeRequestMessage", | ||
namedSchema("start_slot", SszPrimitiveSchemas.UINT64_SCHEMA), | ||
namedSchema("count", SszPrimitiveSchemas.UINT64_SCHEMA)); | ||
} | ||
|
||
@Override | ||
public ExecutionPayloadEnvelopesByRangeRequestMessage createFromBackingNode( | ||
final TreeNode node) { | ||
return new ExecutionPayloadEnvelopesByRangeRequestMessage(this, node); | ||
} | ||
} | ||
|
||
public static final ExecutionPayloadEnvelopesByRangeRequestMessageSchema SSZ_SCHEMA = | ||
new ExecutionPayloadEnvelopesByRangeRequestMessageSchema(); | ||
|
||
private ExecutionPayloadEnvelopesByRangeRequestMessage( | ||
final ExecutionPayloadEnvelopesByRangeRequestMessageSchema type, final TreeNode backingNode) { | ||
super(type, backingNode); | ||
} | ||
|
||
public ExecutionPayloadEnvelopesByRangeRequestMessage( | ||
final UInt64 startSlot, final UInt64 count) { | ||
super(SSZ_SCHEMA, SszUInt64.of(startSlot), SszUInt64.of(count)); | ||
} | ||
|
||
public UInt64 getStartSlot() { | ||
return getField0().get(); | ||
} | ||
|
||
public UInt64 getCount() { | ||
return getField1().get(); | ||
} | ||
|
||
public UInt64 getMaxSlot() { | ||
return getStartSlot().plus(getCount().minusMinZero(1)); | ||
} | ||
|
||
@Override | ||
public int getMaximumResponseChunks() { | ||
return getCount().intValue(); | ||
} | ||
} |
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.