forked from TrueCloudLab/neoneo-go
network: plug in dBFT library
This commit is contained in:
parent
5ad665bc37
commit
fdd5276d3e
29 changed files with 1415 additions and 142 deletions
|
@ -4,31 +4,58 @@ import (
|
|||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/io"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/dbft/payload"
|
||||
)
|
||||
|
||||
// prepareRequest represents dBFT PrepareRequest message.
|
||||
// prepareRequest represents dBFT prepareRequest message.
|
||||
type prepareRequest struct {
|
||||
Timestamp uint32
|
||||
Nonce uint64
|
||||
TransactionHashes []util.Uint256
|
||||
MinerTransaction transaction.Transaction
|
||||
NextConsensus util.Uint160
|
||||
timestamp uint32
|
||||
nonce uint64
|
||||
transactionHashes []util.Uint256
|
||||
minerTx transaction.Transaction
|
||||
nextConsensus util.Uint160
|
||||
}
|
||||
|
||||
var _ payload.PrepareRequest = (*prepareRequest)(nil)
|
||||
|
||||
// EncodeBinary implements io.Serializable interface.
|
||||
func (p *prepareRequest) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteLE(p.Timestamp)
|
||||
w.WriteLE(p.Nonce)
|
||||
w.WriteBE(p.NextConsensus[:])
|
||||
w.WriteArray(p.TransactionHashes)
|
||||
p.MinerTransaction.EncodeBinary(w)
|
||||
w.WriteLE(p.timestamp)
|
||||
w.WriteLE(p.nonce)
|
||||
w.WriteBE(p.nextConsensus[:])
|
||||
w.WriteArray(p.transactionHashes)
|
||||
p.minerTx.EncodeBinary(w)
|
||||
}
|
||||
|
||||
// DecodeBinary implements io.Serializable interface.
|
||||
func (p *prepareRequest) DecodeBinary(r *io.BinReader) {
|
||||
r.ReadLE(&p.Timestamp)
|
||||
r.ReadLE(&p.Nonce)
|
||||
r.ReadBE(p.NextConsensus[:])
|
||||
r.ReadArray(&p.TransactionHashes)
|
||||
p.MinerTransaction.DecodeBinary(r)
|
||||
r.ReadLE(&p.timestamp)
|
||||
r.ReadLE(&p.nonce)
|
||||
r.ReadBE(p.nextConsensus[:])
|
||||
r.ReadArray(&p.transactionHashes)
|
||||
p.minerTx.DecodeBinary(r)
|
||||
}
|
||||
|
||||
// Timestamp implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) Timestamp() uint32 { return p.timestamp }
|
||||
|
||||
// SetTimestamp implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) SetTimestamp(ts uint32) { p.timestamp = ts }
|
||||
|
||||
// Nonce implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) Nonce() uint64 { return p.nonce }
|
||||
|
||||
// SetNonce implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) SetNonce(nonce uint64) { p.nonce = nonce }
|
||||
|
||||
// TransactionHashes implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) TransactionHashes() []util.Uint256 { return p.transactionHashes }
|
||||
|
||||
// SetTransactionHashes implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) SetTransactionHashes(hs []util.Uint256) { p.transactionHashes = hs }
|
||||
|
||||
// NextConsensus implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) NextConsensus() util.Uint160 { return p.nextConsensus }
|
||||
|
||||
// SetNextConsensus implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) SetNextConsensus(nc util.Uint160) { p.nextConsensus = nc }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue