Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/protocol.h
Show All 20 Lines | |||||
public: | public: | ||||
Vote() : error(-1), hash() {} | Vote() : error(-1), hash() {} | ||||
Vote(uint32_t errorIn, uint256 hashIn) : error(errorIn), hash(hashIn) {} | Vote(uint32_t errorIn, uint256 hashIn) : error(errorIn), hash(hashIn) {} | ||||
const uint256 &GetHash() const { return hash; } | const uint256 &GetHash() const { return hash; } | ||||
uint32_t GetError() const { return error; } | uint32_t GetError() const { return error; } | ||||
// serialization support | SERIALIZE_METHODS(Vote, obj) { READWRITE(obj.error, obj.hash); } | ||||
ADD_SERIALIZE_METHODS; | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(error); | |||||
READWRITE(hash); | |||||
} | |||||
}; | }; | ||||
class Response { | class Response { | ||||
uint64_t round; | uint64_t round; | ||||
uint32_t cooldown; | uint32_t cooldown; | ||||
std::vector<Vote> votes; | std::vector<Vote> votes; | ||||
public: | public: | ||||
Response() : round(-1), cooldown(-1) {} | Response() : round(-1), cooldown(-1) {} | ||||
Response(uint64_t roundIn, uint32_t cooldownIn, std::vector<Vote> votesIn) | Response(uint64_t roundIn, uint32_t cooldownIn, std::vector<Vote> votesIn) | ||||
: round(roundIn), cooldown(cooldownIn), votes(votesIn) {} | : round(roundIn), cooldown(cooldownIn), votes(votesIn) {} | ||||
uint64_t getRound() const { return round; } | uint64_t getRound() const { return round; } | ||||
uint32_t getCooldown() const { return cooldown; } | uint32_t getCooldown() const { return cooldown; } | ||||
const std::vector<Vote> &GetVotes() const { return votes; } | const std::vector<Vote> &GetVotes() const { return votes; } | ||||
// serialization support | SERIALIZE_METHODS(Response, obj) { | ||||
ADD_SERIALIZE_METHODS; | READWRITE(obj.round, obj.cooldown, obj.votes); | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(round); | |||||
READWRITE(cooldown); | |||||
READWRITE(votes); | |||||
} | } | ||||
}; | }; | ||||
class Poll { | class Poll { | ||||
uint64_t round; | uint64_t round; | ||||
std::vector<CInv> invs; | std::vector<CInv> invs; | ||||
public: | public: | ||||
Poll(uint64_t roundIn, std::vector<CInv> invsIn) | Poll(uint64_t roundIn, std::vector<CInv> invsIn) | ||||
: round(roundIn), invs(invsIn) {} | : round(roundIn), invs(invsIn) {} | ||||
uint64_t GetRound() const { return round; } | |||||
const std::vector<CInv> &GetInvs() const { return invs; } | const std::vector<CInv> &GetInvs() const { return invs; } | ||||
// serialization support | SERIALIZE_METHODS(Poll, obj) { READWRITE(obj.round, obj.invs); } | ||||
ADD_SERIALIZE_METHODS; | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(round); | |||||
READWRITE(invs); | |||||
} | |||||
}; | }; | ||||
class Hello { | class Hello { | ||||
Delegation delegation; | Delegation delegation; | ||||
std::array<uint8_t, 64> sig; | std::array<uint8_t, 64> sig; | ||||
public: | public: | ||||
Hello(Delegation delegationIn, std::array<uint8_t, 64> sigIn) | Hello(Delegation delegationIn, std::array<uint8_t, 64> sigIn) | ||||
: delegation(std::move(delegationIn)), sig(sigIn) {} | : delegation(std::move(delegationIn)), sig(sigIn) {} | ||||
// serialization support | std::array<uint8_t, 64> GetSig() const { return sig; } | ||||
ADD_SERIALIZE_METHODS; | |||||
template <typename Stream, typename Operation> | SERIALIZE_METHODS(Hello, obj) { READWRITE(obj.delegation, obj.sig); } | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(delegation); | |||||
READWRITE(sig); | |||||
} | |||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROTOCOL_H | #endif // BITCOIN_AVALANCHE_PROTOCOL_H |