Skip to content

ModificationRequest

Dmitry Kochin edited this page Jul 13, 2018 · 4 revisions

ModificationRequest is sent to insert of update rows in Ties.DB. It can contain several rows to be updated or inserted and they can target different tables and tablespaces.

An example of ModificationRequest follows (EBML represented in XML format).

<ModificationRequest type="m">
    <!-- The consistency level expected by the client -->
    <Consistency type="u">0</Consistency>

    <!-- Each request should specify MessageId unique during the connection -->
    <MessageId type="u">1</MessageId>

    <!-- Request can contain any number of Entries -->
    <Entry type="m">
        <EntryHeader type="m">
            <EntryTablespaceName type="8">client-dev.test</EntryTablespaceName>
            <EntryTableName type="8">all_types</EntryTableName>
            <EntryTimestamp type="d">2018-07-13T11:01:24.361Z</EntryTimestamp>

            <!-- For the "insert" requests entry version should be 1 -->
            <EntryVersion type="u">1</EntryVersion>

            <!-- The hash of all the fields of this entry -->
            <EntryFldHash type="b">cc56423295af7088dbcb99ac8176c54ef760b0db3cf5a9235e167524f272e13a</EntryFldHash>

            <!-- The blockchain Ties.DB works with. 60 for Ethereum -->
            <EntryNetwork type="u">60</EntryNetwork>

            <!-- The creator/modifier of the entry -->
            <Signer type="b">ae65baf610bad3f0d71aa3c3a8110c2d62cbeb19</Signer>

            <!-- The signature of EntryHeader by modifier/creator -->
            <Signature type="b">7033b0e422a1a14f38cf756c64ffe101ffa4e700b1d3a5acce0db74c356099b005c1d9cca5e341f2d3af57cf3723ed6813d081b3ebd1605996daad79e49a746726</Signature>
        </EntryHeader>

        <!-- Fields of the record. -->
        <FieldList type="m">
            <Field type="m">
                <FieldName type="8">Id</FieldName>
                <FieldType type="s">uuid</FieldType>
                <FieldValue type="b">2b7d39f0731c4532a852b7a182c1aaa1</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fBinary</FieldName>
                <FieldType type="s">binary</FieldType>
                <FieldValue type="b">e0a61e5ad74f</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fBoolean</FieldName>
                <FieldType type="s">boolean</FieldType>
                <FieldValue type="b">00</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fDecimal</FieldName>
                <FieldType type="s">decimal</FieldType>
                <FieldValue type="b">96fb2d</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fDouble</FieldName>
                <FieldType type="s">double</FieldType>
                <FieldValue type="b">416f00db980276caea8182</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fDuration</FieldName>
                <FieldType type="s">duration</FieldType>
                <FieldValue type="b">9a00efcee47256c00000</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fFloat</FieldName>
                <FieldType type="s">float</FieldType>
                <FieldValue type="b">aefdadfc5d755013dd01</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fInteger</FieldName>
                <FieldType type="s">integer</FieldType>
                <FieldValue type="b">193cf1b0</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fString</FieldName>
                <FieldType type="s">string</FieldType>
                <FieldValue type="b">54686973206973205554462d3820d181d182d180d0bed0bad0b0</FieldValue>
            </Field>
        </FieldList>

        <!-- Cheques that ensure payments for this entry. Not yet implemented (as of Alpha version) -->
        <ChequeList>
        </ChequeList>
    </Entry>
</ModificationRequest>

The ModificationRequest for updating data has the following differences.

<ModificationRequest type="m">
    <Consistency type="u">0</Consistency>
    <MessageId type="u">3</MessageId>
    <Entry type="m">
        <EntryHeader type="m">
            <!-- ... skip ... -->
            
            <!-- You should increment entry version here -->
            <EntryVersion type="u">2</EntryVersion>
            <EntryFldHash type="b">b9a239ef429ef08704add8d94bd39d26f31bc322ec8199ac302bab639fcc8bb0</EntryFldHash>

            <!-- You should specify an old hash of EntryHeader -->
            <EntryOldHash type="b">2f603671de9efa320218c8b7ad43881127cb0430ab811496733746f2d51a5cb6</EntryOldHash>
            
            <!-- ... skip ... -->
        </EntryHeader>
        <FieldList type="m">
            <Field type="m">
                <FieldName type="8">Id</FieldName>
                <FieldType type="s">uuid</FieldType>
                <FieldValue type="b">86ee31dfb1664ceb97b6375ee76cffc3</FieldValue>
            </Field>
            <Field type="m">
                <FieldName type="8">fLong</FieldName>
                <FieldType type="s">long</FieldType>
                <FieldValue type="b">7b</FieldValue>
            </Field>

            <!-- You can skip FieldValue for the fields you want to leave unchanged and specify only FieldHash -->
            <Field type="m">
                <FieldName type="8">fBinary</FieldName>
                <FieldType type="s">binary</FieldType>
                <FieldHash type="b">a6e44f0ec03e1cae0ec12257c1e3f138414ae15d8411cab181cd675be2d3086a</FieldHash>
            </Field>
            <Field type="m">
                <FieldName type="8">fBoolean</FieldName>
                <FieldType type="s">boolean</FieldType>
                <FieldHash type="b">a73f698893fe67e40289d00c99086452b0a1c6dda37d32aac7ee578759883614</FieldHash>
            </Field>
            <!-- ... skip ... -->
        </FieldList>
    </Entry>
</ModificationRequest>

In response to ModificationRequest you get ModificationResponse.

Clone this wiki locally