From b4b1f6f0022015cd139cb846f6be2380a63c2267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 27 Sep 2017 09:47:53 +0300 Subject: [PATCH] Revert "ethereum, mobile: nullable topics for filter criteria" This reverts commit 0773893f4b6498510ac1eb369aeadea7b8b4f2a3. --- interfaces.go | 2 +- mobile/common.go | 55 ---------------------------------------------- mobile/ethereum.go | 12 +++++----- 3 files changed, 7 insertions(+), 62 deletions(-) diff --git a/interfaces.go b/interfaces.go index 8eb655f807..67f236ef75 100644 --- a/interfaces.go +++ b/interfaces.go @@ -146,7 +146,7 @@ type FilterQuery struct { // {{}, {B}} matches any topic in first position, B in second position // {{A}}, {B}} matches topic A in first position, B in second position // {{A, B}}, {C, D}} matches topic (A OR B) in first position, (C OR D) in second position - Topics [][]*common.Hash + Topics [][]common.Hash } // LogFilterer provides access to contract log events using a one-off query or continuous diff --git a/mobile/common.go b/mobile/common.go index 35eaec129c..047d8e1f65 100644 --- a/mobile/common.go +++ b/mobile/common.go @@ -128,61 +128,6 @@ func (h *Hashes) Append(hash *Hash) { h.hashes = append(h.hashes, hash.hash) } -// NullableHashes represents a slice of hashes that can have the null value too. -type NullableHashes struct{ hashes []*common.Hash } - -// NewNullableHashes creates a slice of uninitialized NullableHashes. -func NewNullableHashes(size int) *NullableHashes { - return &NullableHashes{ - hashes: make([]*common.Hash, size), - } -} - -// NewNullableHashesEmpty creates an empty slice of NullableHashes values. -func NewNullableHashesEmpty() *NullableHashes { - return NewNullableHashes(0) -} - -// Size returns the number of hashes in the slice. -func (h *NullableHashes) Size() int { - return len(h.hashes) -} - -// Get returns the hash at the given index from the slice. -func (h *NullableHashes) Get(index int) (hash *Hash, _ error) { - if index < 0 || index >= len(h.hashes) { - return nil, errors.New("index out of bounds") - } - if h.hashes[index] == nil { - return nil, nil - } - return &Hash{*h.hashes[index]}, nil -} - -// Set sets the Hash at the given index in the slice. -func (h *NullableHashes) Set(index int, hash *Hash) error { - if index < 0 || index >= len(h.hashes) { - return errors.New("index out of bounds") - } - if hash == nil { - h.hashes[index] = nil - return nil - } - copy := hash.hash - h.hashes[index] = © - return nil -} - -// Append adds a new Hash element to the end of the slice. -func (h *NullableHashes) Append(hash *Hash) { - if hash == nil { - h.hashes = append(h.hashes, nil) - return - } - copy := hash.hash - h.hashes = append(h.hashes, ©) -} - // Address represents the 20 byte address of an Ethereum account. type Address struct { address common.Address diff --git a/mobile/ethereum.go b/mobile/ethereum.go index c433789554..c9bb3013c2 100644 --- a/mobile/ethereum.go +++ b/mobile/ethereum.go @@ -85,12 +85,12 @@ func (p *SyncProgress) GetPulledStates() int64 { return int64(p.progress.Pulled func (p *SyncProgress) GetKnownStates() int64 { return int64(p.progress.KnownStates) } // Topics is a set of topic lists to filter events with. -type Topics struct{ topics [][]*common.Hash } +type Topics struct{ topics [][]common.Hash } // NewTopics creates a slice of uninitialized Topics. func NewTopics(size int) *Topics { return &Topics{ - topics: make([][]*common.Hash, size), + topics: make([][]common.Hash, size), } } @@ -105,15 +105,15 @@ func (t *Topics) Size() int { } // Get returns the topic list at the given index from the slice. -func (t *Topics) Get(index int) (hashes *NullableHashes, _ error) { +func (t *Topics) Get(index int) (hashes *Hashes, _ error) { if index < 0 || index >= len(t.topics) { return nil, errors.New("index out of bounds") } - return &NullableHashes{t.topics[index]}, nil + return &Hashes{t.topics[index]}, nil } // Set sets the topic list at the given index in the slice. -func (t *Topics) Set(index int, topics *NullableHashes) error { +func (t *Topics) Set(index int, topics *Hashes) error { if index < 0 || index >= len(t.topics) { return errors.New("index out of bounds") } @@ -122,7 +122,7 @@ func (t *Topics) Set(index int, topics *NullableHashes) error { } // Append adds a new topic list to the end of the slice. -func (t *Topics) Append(topics *NullableHashes) { +func (t *Topics) Append(topics *Hashes) { t.topics = append(t.topics, topics.hashes) }