-
Notifications
You must be signed in to change notification settings - Fork 14
/
proposal.go
34 lines (26 loc) · 641 Bytes
/
proposal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package pbft
import (
"bytes"
"time"
)
// Proposal is the default proposal
type Proposal struct {
// Data is an arbitrary set of data to approve in consensus
Data []byte
// Time is the time to create the proposal
Time time.Time
// Hash is the digest of the data to seal
Hash []byte
}
// Equal compares whether two proposals have the same hash
func (p *Proposal) Equal(pp *Proposal) bool {
return bytes.Equal(p.Hash, pp.Hash)
}
// Copy makes a copy of the Proposal
func (p *Proposal) Copy() *Proposal {
pp := new(Proposal)
*pp = *p
pp.Data = append([]byte{}, p.Data...)
pp.Hash = append([]byte{}, p.Hash...)
return pp
}