Added sort method to ContractAttributes array
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user