mobile: Add management methods to {Addresses,Topics,Hashes} structures

This commit is contained in:
Nicolas Guillaume
2017-05-23 11:16:25 +02:00
parent da636c53d6
commit 30cc1c3bf0
2 changed files with 60 additions and 0 deletions

View File

@ -87,6 +87,18 @@ func (p *SyncProgress) GetKnownStates() int64 { return int64(p.progress.KnownS
// Topics is a set of topic lists to filter events with.
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),
}
}
// NewTopicsEmpty creates an empty slice of Topics values.
func NewTopicsEmpty() *Topics {
return NewTopics(0)
}
// Size returns the number of topic lists inside the set
func (t *Topics) Size() int {
return len(t.topics)
@ -109,6 +121,11 @@ func (t *Topics) Set(index int, topics *Hashes) error {
return nil
}
// Append adds a new topic list to the end of the slice.
func (t *Topics) Append(topics *Hashes) {
t.topics = append(t.topics, topics.hashes)
}
// FilterQuery contains options for contact log filtering.
type FilterQuery struct {
query ethereum.FilterQuery