diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-03 09:42:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-03 09:42:58 +0800 |
commit | 6c4617f42f31014727bdc6f5731c32fc21004101 (patch) | |
tree | dd62c88c83ce1c831826126fbf4e63cb4388fdde /common | |
parent | 819030245cf4114429f8d8cdd32488a15a8666ee (diff) | |
download | dexon-consensus-6c4617f42f31014727bdc6f5731c32fc21004101.tar dexon-consensus-6c4617f42f31014727bdc6f5731c32fc21004101.tar.gz dexon-consensus-6c4617f42f31014727bdc6f5731c32fc21004101.tar.bz2 dexon-consensus-6c4617f42f31014727bdc6f5731c32fc21004101.tar.lz dexon-consensus-6c4617f42f31014727bdc6f5731c32fc21004101.tar.xz dexon-consensus-6c4617f42f31014727bdc6f5731c32fc21004101.tar.zst dexon-consensus-6c4617f42f31014727bdc6f5731c32fc21004101.zip |
core: DEXON Consensus Timestamp Algorithm. (#29)
Diffstat (limited to 'common')
-rw-r--r-- | common/types.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/common/types.go b/common/types.go index 0a78111..9dc9f1c 100644 --- a/common/types.go +++ b/common/types.go @@ -20,6 +20,7 @@ package common import ( "bytes" "encoding/hex" + "time" ) const ( @@ -58,3 +59,10 @@ type Hashes []Hash func (hs Hashes) Len() int { return len(hs) } func (hs Hashes) Less(i, j int) bool { return bytes.Compare(hs[i][:], hs[j][:]) < 0 } func (hs Hashes) Swap(i, j int) { hs[i], hs[j] = hs[j], hs[i] } + +// ByTime implements sort.Interface for time.Time. +type ByTime []time.Time + +func (t ByTime) Len() int { return len(t) } +func (t ByTime) Swap(i, j int) { t[i], t[j] = t[j], t[i] } +func (t ByTime) Less(i, j int) bool { return t[i].Before(t[j]) } |