aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/validator.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-10 10:39:29 +0800
committerGitHub <noreply@github.com>2018-08-10 10:39:29 +0800
commit99d9591e5f0af54bf06f41cfd2658cfcc9ee6436 (patch)
tree784fb11e9830c97056524bb1330df5b551453a80 /core/types/validator.go
parent36cce13f83e6aa2e3ee67b787f6cb133066425a9 (diff)
downloaddexon-consensus-99d9591e5f0af54bf06f41cfd2658cfcc9ee6436.tar
dexon-consensus-99d9591e5f0af54bf06f41cfd2658cfcc9ee6436.tar.gz
dexon-consensus-99d9591e5f0af54bf06f41cfd2658cfcc9ee6436.tar.bz2
dexon-consensus-99d9591e5f0af54bf06f41cfd2658cfcc9ee6436.tar.lz
dexon-consensus-99d9591e5f0af54bf06f41cfd2658cfcc9ee6436.tar.xz
dexon-consensus-99d9591e5f0af54bf06f41cfd2658cfcc9ee6436.tar.zst
dexon-consensus-99d9591e5f0af54bf06f41cfd2658cfcc9ee6436.zip
core: Add block hash signature functions in core/ctypto.go. (#39)
Diffstat (limited to 'core/types/validator.go')
-rw-r--r--core/types/validator.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/core/types/validator.go b/core/types/validator.go
index 48ce586..86c3acc 100644
--- a/core/types/validator.go
+++ b/core/types/validator.go
@@ -1,15 +1,15 @@
// Copyright 2018 The dexon-consensus-core Authors
// This file is part of the dexon-consensus-core library.
//
-// The dexon-consensus-core library is free software: you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public License as
+// The dexon-consensus-core library is free software: you can redistribute it
+// and/or modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
-// The dexon-consensus-core library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
+// The dexon-consensus-core library is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+// General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the dexon-consensus-core library. If not, see
@@ -18,6 +18,8 @@
package types
import (
+ "bytes"
+
"github.com/dexon-foundation/dexon-consensus-core/common"
)
@@ -25,3 +27,18 @@ import (
type ValidatorID struct {
common.Hash
}
+
+// ValidatorIDs implements sort.Interface for ValidatorID.
+type ValidatorIDs []ValidatorID
+
+func (v ValidatorIDs) Len() int {
+ return len(v)
+}
+
+func (v ValidatorIDs) Less(i int, j int) bool {
+ return bytes.Compare([]byte(v[i].Hash[:]), []byte(v[j].Hash[:])) == -1
+}
+
+func (v ValidatorIDs) Swap(i int, j int) {
+ v[i], v[j] = v[j], v[i]
+}