Skip to content

Commit

Permalink
Phoenix: implement Market deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
skynetcap committed Nov 19, 2023
1 parent 14be735 commit 79180ed
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mmorrell.phoenix.model;

import com.google.common.io.Files;
import com.mmorrell.phoenix.util.PhoenixUtil;
import lombok.Builder;
import lombok.Data;
import org.bitcoinj.core.Utils;
Expand Down Expand Up @@ -35,8 +36,21 @@ public static PhoenixMarket readPhoenixMarket(byte[] data, PhoenixMarketHeader h
long bidsSize =
16 + 16 + (16 + FIFOOrderId.FIFO_ORDER_ID_SIZE + FIFORestingOrder.FIFO_RESTING_ORDER_SIZE) * header.getBidsSize();

System.out.println("Bid size: " + bidsSize);
byte[] bidBuffer = Arrays.copyOfRange(data, 880, (int) bidsSize);

int offset = 0;
offset += 16; // skip rbtree header
// Skip node allocator size
offset += 8;

int bumpIndex = PhoenixUtil.readInt32(bidBuffer, offset);
offset += 4;

int freeListHead = PhoenixUtil.readInt32(bidBuffer, offset);
offset += 4;


return phoenixMarket;
}

Expand Down

0 comments on commit 79180ed

Please sign in to comment.