Back to project page bitcoin-wallet.
The source code is released under:
Copyright (C) 2011 by Caleb Anderson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the ...
If you think the Android project bitcoin-wallet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.dirtyfilthy.bitcoin.protocol; /* w w w . ja va 2 s . c om*/ import java.io.DataInputStream; import java.io.IOException; import java.util.Vector; import net.dirtyfilthy.bitcoin.core.Block; public class HeadersPacket extends Packet { Vector<Block> headers=new Vector<Block>(); public HeadersPacket(long ver) { super(ver, "headers"); } public HeadersPacket() { super(); setCommand("headers"); } public byte[] create(){ writeUnsignedVarInt(headers.size()); for(Block b : headers){ dataBuffer.put(b.toByteArray()); } return toByteArray(); } public void readData(DataInputStream in) throws IOException{ headers.clear(); int items=(int) readUnsignedVarInt(in); System.out.println("header items :"+items); for(int i=0;i<items;i++){ // SER_BLOCKHEADERONLY is defined in original but only used for disk access // we need to get the (always zero) txCount so we pass in includeTransactions=true headers.add(new Block(in,true)); } } public Vector<Block> headers(){ return this.headers; } }