All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hedera.hapi.block.schema.EndOfStreamSchema Maven / Gradle / Ivy

There is a newer version: 0.54.0
Show newest version
package com.hedera.hapi.block.schema;

import com.hedera.pbj.runtime.FieldDefinition;
import com.hedera.pbj.runtime.FieldType;
import com.hedera.pbj.runtime.Schema;


/**
 * Schema for EndOfStream model object. Generate based on protobuf schema.
 */
public final class EndOfStreamSchema implements Schema {

    // -- FIELD DEFINITIONS ---------------------------------------------

    /**
     * (1) A response code.
     * 

* This code indicates the reason the stream ended.
* This value MUST be set to a non-default value. */ public static final FieldDefinition STATUS = new FieldDefinition("status", FieldType.ENUM, false, false, false, 1); /** * (2) The number of the last completed and _verified_ block. *

* Nodes SHOULD only end a stream after a block state proof to avoid * the need to resend items.
* If status is a failure code, the source node MUST start a new * stream at the beginning of the first block _following_ this number * (e.g. if this is 91827362983, then the new stream must start with * the _header_ for block 91827362984). */ public static final FieldDefinition BLOCK_NUMBER = new FieldDefinition("block_number", FieldType.UINT64, false, false, false, 2); // -- OTHER METHODS ------------------------------------------------- /** * Check if a field definition belongs to this schema. * * @param f field def to check * @return true if it belongs to this schema */ public static boolean valid(FieldDefinition f) { return f != null && getField(f.number()) == f; } /** * Get a field definition given a field number * * @param fieldNumber the fields number to get def for * @return field def or null if field number does not exist */ public static FieldDefinition getField(final int fieldNumber) { return switch(fieldNumber) { case 1 -> STATUS; case 2 -> BLOCK_NUMBER; default -> null; }; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy