Synchronising event streams
The present disclosure proposes methods, devices and systems for synchronising a plurality of event streams using an atomic blockchain transaction, the transaction having multiple inputs, each spending a dust output of a previous transaction for a respective event stream among the plurality, each input having an unspent dust output and a data payload.
1 . A computer implemented method for synchronising a plurality of event streams, each event stream implemented as a plurality of linked blockchain transactions, the method implemented by a platform processor associated with an application programming interface (API), the method comprising the steps of:
receiving a request from a client to update a plurality of existing event streams associated with a blockchain;
from the request, obtaining a current event to be appended to each of said event streams;
for each said event stream, identifying the last blockchain transaction associated with the event stream; and
creating a blockchain transaction for the current event to be appended to each event stream in order to synchronise the event streams, the blockchain transaction comprising:
for each said event stream:
an input spending a dust output associated with the last transaction of the event stream, and
a respective unspent transaction output being a dust output associated with the respective event stream; and
an unspent transaction output associated with event data representing the current event such that the blockchain transaction becomes the last transaction in each of the event streams.
2 . The method of claim 1 , wherein for each event stream among the plurality of event streams, the method comprises mapping an input associated with dust to a respective output based on an arbitrary or regular pattern, to track a state of the respective event stream.
3 . The method of claim 2 , wherein when x is an index associated with an input for a respective event stream, the regular pattern is provided by the steps of:
mapping the dust of input at index x with an output stored at index 2x; and
identifying the state of the respective event stream based on an output stored at index 2x+1;
wherein, the input indices x are provided from 0 to M−1 for the blockchain transaction, M being the number of event streams.
4 . The method of claim 1 , wherein the API is associated with a Hypertext Transfer Protocol (HTTP) endpoint, and wherein:
the request received from the client is based on a HTTP transmission protocol format; and
the endpoint is a separate or specific endpoint for synchronising the plurality of event streams.
5 . The method of claim 1 , comprising the step of obtaining a target index for one or more event stream among the plurality of event streams for appending the current event, and optionally wherein the target index for the one or more event streams among the plurality is provided in the request from the client.
6 . The method of claim 4 , wherein the request is associated with a digital signature.
7 . The method of claim 5 , wherein, based on a determination that an actual next available index value for an event stream is the same as the target index for the respective event stream, the method includes:
appending the current event to the respective event stream;
otherwise, the method includes generating an error notification.
8 . The method of claim 1 , comprising the step of locking each event stream associated with the request from the client until the current event has been appended to each of the plurality of M event streams, or until an error message is generated for one or more of the event streams in said plurality.
9 . The method of claim 1 , wherein a dust input index for each of the inputs of the blockchain transaction is recorded in the respective event stream associated with the input; and optionally wherein a dust output index or an event data index for each of the n=M inputs of the blockchain transaction is recorded in the respective event stream associated with the n th input.
10 . The method of claim 1 , wherein, for each event stream among the plurality of event streams, the method comprises creating a key pair specific to each index associated with the respective event stream.
11 . The method of claim 1 , wherein, each event stream among the plurality of event streams is associated with a key chain K such that K=K 0 to i , where i is an integer representing a current index value or length or current number of events associated with the given event stream, the method comprising the steps of:
obtaining a key pair K i−1 associated with the identified last transaction for the given event stream;
deriving a key pair K i for the current event for the given event stream; wherein:
the spend of the respective input is authorised with the obtained key pair K i−1 for the last transaction of the respective event stream; and
the respective dust output is associated with a locking script secured with the derived key pair K i for the respective event stream.
12 . The method of claim 1 , wherein the blockchain transaction further comprises:
an input associated with a digital asset, optionally wherein the digital asset is associated with an operational float; and
one or more change outputs associated with the digital asset.
13 . The method of claim 1 , comprising the steps of:
responsive to appending the current event to each of the plurality of event streams, obtaining a new current index value for each of the event streams; and
providing a response array of the obtained new index values for the plurality of event streams.
14 . The method of claim 1 , comprising:
submitting the blockchain transaction to the blockchain, optionally wherein the step of submitting comprises including the transaction in a subsequent block associated with the blockchain to be mined; and
sending a result associated with each of the plurality of synchronised event streams to the client.
15 . The method of claim 14 , wherein the result associated with each of the plurality of event stream includes a certificate confirming at least one of the following:
the blockchain transaction identifier within which the event was submitted to the blockchain;
a Merkle inclusion proof of the blockchain transaction to a header in the blockchain; and
a copy of the block header in which said blockchain transaction was included.
16 . The method of claim 1 , wherein at least one of:
the event data associated with the current for synchronising the plurality of event streams is the same for all event streams in the plurality;
the event data associated with the current event for synchronising the plurality of event streams is different for at one or more of the event streams in the plurality of event streams;
the event data associated with the current for synchronising the plurality of event streams comprises metadata; or
the event data associated with the current for synchronising the plurality of event streams contains only metadata.
17 . A computing device comprising a processor and memory, the memory including executable instructions that, as a result of execution by the processor, causes the computing device to perform a computer-implemented method for synchronising a plurality of event streams associated with a blockchain, the method implemented by a platform processor associated with an application programming interface (API), the method comprising the steps of:
receiving a request from a client to update a plurality of existing event streams associated with the blockchain;
from the request, obtaining a current event to be appended to each of said event streams;
for each said event stream, identifying the last blockchain transaction associated with the event stream; and
creating a blockchain transaction for the current event to be appended to each event stream in order to synchronise the event streams, the blockchain transaction comprising:
for each said event stream:
an input spending a dust output associated with the last transaction of the event stream, and
a respective unspent transaction output being a dust output for the transaction associated with the event stream; and
an unspent transaction output associated with event data representing the current event, the computing device pertaining to a platform processor;
such that the blockchain transaction becomes the last transaction in each of the event streams.
18 . A non-transitory computer-readable storage medium having stored thereon executable instructions that, as a result of being executed by a processor of a computer, cause the computer to perform a method for synchronising a plurality of event streams associated with a blockchain, the method implemented by a platform processor associated with an application programming interface (API), the method comprising the steps of:
receiving a request from a client to update a plurality of existing event streams associated with the blockchain, n being an integer from 1 to M, where M≥2
from the request, obtaining a current event to be appended to each event stream among the plurality M of event streams;
for each event stream, identifying a previous blockchain transaction associated with the event stream; and
creating a blockchain transaction for the current event to be appended to each event stream among the plurality of M event streams in order to synchronise the plurality M of event streams, the blockchain transaction comprising:
for each said event stream:
an input spending a dust output associated with the last transaction of the event stream, and
a respective unspent transaction output being a dust output for the transaction associated with the event stream; and
an unspent transaction output associated with event data representing the current event;
such that the blockchain transaction becomes the last transaction in each of the event streams.