-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement BlobSidecarsByRoot RPC method
- Loading branch information
1 parent
596a9ac
commit c4d09c7
Showing
13 changed files
with
476 additions
and
3 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/BlobIdentifier.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,57 @@ | ||
/* | ||
* Copyright ConsenSys Software Inc., 2023 | ||
* | ||
* 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 org.apache.tuweni.bytes.Bytes32; | ||
import tech.pegasys.teku.infrastructure.ssz.containers.Container2; | ||
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; | ||
import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; | ||
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 class BlobIdentifier extends Container2<BlobIdentifier, SszBytes32, SszUInt64> { | ||
|
||
public static class BlobIdentifierSchema | ||
extends ContainerSchema2<BlobIdentifier, SszBytes32, SszUInt64> { | ||
|
||
private BlobIdentifierSchema() { | ||
super(SszPrimitiveSchemas.BYTES32_SCHEMA, SszPrimitiveSchemas.UINT64_SCHEMA); | ||
} | ||
|
||
@Override | ||
public BlobIdentifier createFromBackingNode(final TreeNode node) { | ||
return new BlobIdentifier(node); | ||
} | ||
} | ||
|
||
public static final BlobIdentifierSchema SSZ_SCHEMA = new BlobIdentifierSchema(); | ||
|
||
private BlobIdentifier(final TreeNode node) { | ||
super(SSZ_SCHEMA, node); | ||
} | ||
|
||
public BlobIdentifier(final Bytes32 root, final UInt64 index) { | ||
super(SSZ_SCHEMA, SszBytes32.of(root), SszUInt64.of(index)); | ||
} | ||
|
||
public Bytes32 getBlockRoot() { | ||
return getField0().get(); | ||
} | ||
|
||
public UInt64 getIndex() { | ||
return getField1().get(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...asys/teku/spec/datastructures/networking/libp2p/rpc/BlobSidecarsByRootRequestMessage.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,58 @@ | ||
/* | ||
* 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 java.util.List; | ||
import tech.pegasys.teku.infrastructure.ssz.SszList; | ||
import tech.pegasys.teku.infrastructure.ssz.impl.SszListImpl; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.impl.AbstractSszListSchema; | ||
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
|
||
public class BlobSidecarsByRootRequestMessage extends SszListImpl<BlobIdentifier> | ||
implements SszList<BlobIdentifier>, RpcRequest { | ||
|
||
public static class BlobSidecarsByRootRequestMessageSchema | ||
extends AbstractSszListSchema<BlobIdentifier, BlobSidecarsByRootRequestMessage> { | ||
|
||
public BlobSidecarsByRootRequestMessageSchema(final UInt64 maxLength) { | ||
super(BlobIdentifier.SSZ_SCHEMA, maxLength.longValue()); | ||
} | ||
|
||
@Override | ||
public BlobSidecarsByRootRequestMessage createFromBackingNode(final TreeNode node) { | ||
return new BlobSidecarsByRootRequestMessage(this, node); | ||
} | ||
} | ||
|
||
public BlobSidecarsByRootRequestMessage( | ||
final BlobSidecarsByRootRequestMessageSchema schema, final List<BlobIdentifier> identifiers) { | ||
super(schema, schema.createTreeFromElements(identifiers)); | ||
} | ||
|
||
private BlobSidecarsByRootRequestMessage( | ||
final BlobSidecarsByRootRequestMessageSchema schema, final TreeNode node) { | ||
super(schema, node); | ||
} | ||
|
||
@Override | ||
public int getMaximumRequestChunks() { | ||
return size(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BlobSidecarsByRootRequestMessage{" + super.toString() + "}"; | ||
} | ||
} |
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.