From eedf4fa888a5b4bf8e275d97f43a2ae194f17dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Thu, 11 Aug 2022 18:34:59 +0300 Subject: [PATCH 1/5] New fields on AccountQueryOptions. --- data/api/options.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/api/options.go b/data/api/options.go index 400093a38..f18c6a55a 100644 --- a/data/api/options.go +++ b/data/api/options.go @@ -4,6 +4,8 @@ package api type AccountQueryOptions struct { OnFinalBlock bool OnStartOfEpoch uint32 + OnBlockNonce uint64 + OnBlockHash string } // BlockQueryOptions holds options for block queries From 3ab58f631112d35732e867eb5d6f2ef561ba5ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Fri, 12 Aug 2022 13:37:43 +0300 Subject: [PATCH 2/5] Adjust AccountQueryOptions. --- data/api/options.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/api/options.go b/data/api/options.go index f18c6a55a..626220f18 100644 --- a/data/api/options.go +++ b/data/api/options.go @@ -4,8 +4,9 @@ package api type AccountQueryOptions struct { OnFinalBlock bool OnStartOfEpoch uint32 - OnBlockNonce uint64 - OnBlockHash string + BlockNonce uint64 + BlockHash string + BlockRootHash string } // BlockQueryOptions holds options for block queries From be24d296caaa03d333641a3d7166835a29d6ab16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Sat, 13 Aug 2022 17:16:39 +0300 Subject: [PATCH 3/5] Handle zero-values, as well. --- data/api/options.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/api/options.go b/data/api/options.go index 626220f18..0316d52cf 100644 --- a/data/api/options.go +++ b/data/api/options.go @@ -3,8 +3,8 @@ package api // AccountQueryOptions holds options for account queries type AccountQueryOptions struct { OnFinalBlock bool - OnStartOfEpoch uint32 - BlockNonce uint64 + OnStartOfEpoch *uint32 + BlockNonce *uint64 BlockHash string BlockRootHash string } From d498e11dd0399bebd998a88720d180fba0fff3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Sat, 13 Aug 2022 17:27:50 +0300 Subject: [PATCH 4/5] Define optional values as structs. --- core/optionals.go | 13 +++++++++++++ data/api/options.go | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 core/optionals.go diff --git a/core/optionals.go b/core/optionals.go new file mode 100644 index 000000000..d2af955e9 --- /dev/null +++ b/core/optionals.go @@ -0,0 +1,13 @@ +package core + +// OptionalUint32 holds an optional uint32 value +type OptionalUint32 struct { + Value uint32 + HasValue bool +} + +// OptionalUint64 holds an optional uint64 value +type OptionalUint64 struct { + Value uint64 + HasValue bool +} diff --git a/data/api/options.go b/data/api/options.go index 0316d52cf..d69001e85 100644 --- a/data/api/options.go +++ b/data/api/options.go @@ -1,10 +1,12 @@ package api +import "github.com/ElrondNetwork/elrond-go-core/core" + // AccountQueryOptions holds options for account queries type AccountQueryOptions struct { OnFinalBlock bool - OnStartOfEpoch *uint32 - BlockNonce *uint64 + OnStartOfEpoch core.OptionalUint32 + BlockNonce core.OptionalUint64 BlockHash string BlockRootHash string } From a7d8c4aeaa8797eecf41a3939e81af23c15758c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Sat, 13 Aug 2022 22:37:23 +0300 Subject: [PATCH 5/5] Fix type of fields. --- data/api/options.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/api/options.go b/data/api/options.go index d69001e85..a38f13485 100644 --- a/data/api/options.go +++ b/data/api/options.go @@ -7,8 +7,8 @@ type AccountQueryOptions struct { OnFinalBlock bool OnStartOfEpoch core.OptionalUint32 BlockNonce core.OptionalUint64 - BlockHash string - BlockRootHash string + BlockHash []byte + BlockRootHash []byte } // BlockQueryOptions holds options for block queries