fix: update VoteAccount format

This commit is contained in:
Tyera Eulberg
2019-09-26 16:00:32 -06:00
committed by Michael Vines
parent e0f51fbcaf
commit 19f4cf10bb

View File

@ -28,6 +28,10 @@ export type EpochCredits = {|
* @private * @private
*/ */
const VoteAccountLayout = BufferLayout.struct([ const VoteAccountLayout = BufferLayout.struct([
Layout.publicKey('nodePubkey'),
Layout.publicKey('authorizedVoterPubkey'),
Layout.publicKey('authorizedWithdrawerPubkey'),
BufferLayout.u8('commission'),
BufferLayout.nu64(), // votes.length BufferLayout.nu64(), // votes.length
BufferLayout.seq( BufferLayout.seq(
BufferLayout.struct([ BufferLayout.struct([
@ -37,9 +41,6 @@ const VoteAccountLayout = BufferLayout.struct([
BufferLayout.offset(BufferLayout.u32(), -8), BufferLayout.offset(BufferLayout.u32(), -8),
'votes', 'votes',
), ),
Layout.publicKey('nodePubkey'),
Layout.publicKey('authorizedVoterPubkey'),
BufferLayout.u8('commission'),
BufferLayout.u8('rootSlotValid'), BufferLayout.u8('rootSlotValid'),
BufferLayout.nu64('rootSlot'), BufferLayout.nu64('rootSlot'),
BufferLayout.nu64('epoch'), BufferLayout.nu64('epoch'),
@ -61,10 +62,11 @@ const VoteAccountLayout = BufferLayout.struct([
* VoteAccount class * VoteAccount class
*/ */
export class VoteAccount { export class VoteAccount {
votes: Array<Lockout>;
nodePubkey: PublicKey; nodePubkey: PublicKey;
authorizedVoterPubkey: PublicKey; authorizedVoterPubkey: PublicKey;
authorizedWithdrawerPubkey: PublicKey;
commission: number; commission: number;
votes: Array<Lockout>;
rootSlot: number | null; rootSlot: number | null;
epoch: number; epoch: number;
credits: number; credits: number;
@ -81,6 +83,9 @@ export class VoteAccount {
const va = VoteAccountLayout.decode(buffer, 0); const va = VoteAccountLayout.decode(buffer, 0);
va.nodePubkey = new PublicKey(va.nodePubkey); va.nodePubkey = new PublicKey(va.nodePubkey);
va.authorizedVoterPubkey = new PublicKey(va.authorizedVoterPubkey); va.authorizedVoterPubkey = new PublicKey(va.authorizedVoterPubkey);
va.authorizedWithdrawerPubkey = new PublicKey(
va.authorizedWithdrawerPubkey,
);
if (!va.rootSlotValid) { if (!va.rootSlotValid) {
va.rootSlot = null; va.rootSlot = null;
} }