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
+6 -4
View File
@@ -2,6 +2,7 @@ package fakes
import (
"github.com/8thlight/vulcanizedb/pkg/core"
"sort"
)
type Blockchain struct {
@@ -11,15 +12,16 @@ type Blockchain struct {
WasToldToStop bool
}
func (blockchain *Blockchain) GetContractAttributes(contractHash string) ([]core.ContractAttribute, error) {
var contractAttribute []core.ContractAttribute
func (blockchain *Blockchain) GetContractAttributes(contractHash string) (core.ContractAttributes, error) {
var contractAttributes core.ContractAttributes
attributes, ok := blockchain.contractAttributes[contractHash]
if ok {
for key, _ := range attributes {
contractAttribute = append(contractAttribute, core.ContractAttribute{Name: key, Type: "string"})
contractAttributes = append(contractAttributes, core.ContractAttribute{Name: key, Type: "string"})
}
}
return contractAttribute, nil
sort.Sort(contractAttributes)
return contractAttributes, nil
}
func (blockchain *Blockchain) GetContractStateAttribute(contractHash string, attributeName string) (*string, error) {