12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697(*****************************************************************************)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typet={version:Version.t;network_version:Network_version.t;commit_info:commit_infooption;}andcommit_info={commit_hash:string;commit_date:string}(** the namespace used for the node metrics *)letnamespace="octez"letcommit_info_encoding=letopenData_encodinginconv(fun{commit_hash;commit_date}->(commit_hash,commit_date))(fun(commit_hash,commit_date)->{commit_hash;commit_date})(obj2(req"commit_hash"string)(req"commit_date"string))(* Locally defined encoding for Version.additional_info *)letadditional_info_encoding=letopenData_encodinginletopenVersioninunion[case(Tag0)~title:"Dev"(constant"dev")(functionDev->Some()|_->None)(fun()->Dev);case(Tag1)~title:"RC"(obj1(req"rc"int31))(functionRCn->Somen|_->None)(funn->RCn);case(Tag2)~title:"Release"(constant"release")(functionRelease->Some()|_->None)(fun()->Release);case(Tag3)~title:"RC_dev"(obj1(req"rc_dev"int31))(functionRC_devn->Somen|_->None)(funn->RC_devn);](* The encoding is defined here to keep [Version] "Data_encoding free"*)letversion_encoding=letopenData_encodinginconv(fun({major;minor;additional_info}:Version.t)->(major,minor,additional_info))(fun(major,minor,additional_info)->{major;minor;additional_info})(obj3(req"major"int31)(req"minor"int31)(req"additional_info"additional_info_encoding))letencoding=letopenData_encodinginconv(fun{version;network_version;commit_info}->(version,network_version,commit_info))(fun(version,network_version,commit_info)->{version;network_version;commit_info})(obj3(req"version"version_encoding)(req"network_version"Network_version.encoding)(req"commit_info"(optioncommit_info_encoding)))