123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020-2024 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);case(Tag4)~title:"Beta"(obj1(req"beta"int31))(functionBetan->Somen|_->None)(funn->Betan);case(Tag5)~title:"Beta_dev"(obj1(req"beta_dev"int31))(functionBeta_devn->Somen|_->None)(funn->Beta_devn);](* The encoding is defined here to keep [Version] "Data_encoding free"*)letversion_encoding=letopenData_encodinginconv(fun({product=_;major;minor;additional_info}:Version.t)->(major,minor,additional_info))(fun(major,minor,additional_info)->{product=Octez;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)))