Added sort method to ContractAttributes array

This commit is contained in:
Matt Krump
2017-11-28 14:05:39 -06:00
parent aa3318451b
commit 1bae6db483
7 changed files with 27 additions and 14 deletions
+1 -1
View File
@@ -5,6 +5,6 @@ type Blockchain interface {
SubscribeToBlocks(blocks chan Block)
StartListening()
StopListening()
GetContractAttributes(contractHash string) ([]ContractAttribute, error)
GetContractAttributes(contractHash string) (ContractAttributes, error)
GetContractStateAttribute(contractHash string, attributeName string) (*string, error)
}
+13
View File
@@ -9,3 +9,16 @@ type ContractAttribute struct {
Name string
Type string
}
type ContractAttributes []ContractAttribute
func (s ContractAttributes) Len() int {
return len(s)
}
func (s ContractAttributes) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s ContractAttributes) Less(i, j int) bool {
return s[i].Name < s[j].Name
}