Message structure (Protocolbuffers)¶
Creating a network of TrustChain peers which only run a Java version of TrustChain is not very useful. Therefore the TrustChain blocks and messages should be compatible with many platforms, so cross-platform connection is possible. For the storage of the chain this is achieved by using SQLite, which has implementation for many platforms. For sending messages (blocks and crawlrequests) this compatibility can be achieved by using Google’s Protocolbuffers, which is a cross-platform data serialization mechanism. When implementations across platforms use the same Protocolbuffers setup, messaging will across these platforms will be possible.
Making changes¶
Protocolbuffers is used to create the structure of messages. This includes all the messages used by the network overlay (Connection between peers) and the structures of the Trustchain related objects like TrustChainBlock and CrawlRequest. A complete overview of the message structure can be found in Complete structure. With Protocolbuffers the corresponding Java classes can be compiled, so it is possible to call the structures as objects. Making changes and recompiling the Java classes is quite easy, just follow the tutorial of ProtocolBuffers and you should be fine. When making changes, don’t forget to also update the database structure if necessary.
Complete structure¶
The complete structure of all parsable objects as defined in protocolbuffers.
Message¶
bytessource_public_keystringsource_namebytesdestination_addressint32destination_portint32typePayloadpayload
Payload¶
IntroductionRequestintroductionRequestIntroductionResponseintroductionResponsePuncturepuncturePunctureRequestpunctureRequestTrustChainBlockblockCrawlRequestcrawlRequest
TrustChainBlock¶
bytespublic_keyint32sequence_numberbyteslink_public_keyint32link_sequence_numberbytesprevious_hashbytessignatureTransactiontransactiongoogle.protobuf.Timestampinsert_time
Transaction¶
bytesunformattedstringformatClaimclaim
Claim¶
bytesnamegoogle.protobuf.Timestamptimestampint32validity_termbytesproof_format
CrawlRequest¶
bytespublic_keyint32requested_sequence_numberint32limit
IntroductionRequest¶
int64connection_type
IntroductionResponse¶
int64connection_typestringinternal_source_socketPeerinvitee- repeated
Peerpeers
Puncture¶
stringsourceSocket
PunctureRequest¶
stringsource_socketPeerpuncture_peer
Peer¶
bytesaddressint32portbytespublic_keystringnameint32connectionType