Exemple #1
0
 public static new Headers FromStream(Stream s)
 {
     Headers x = new Headers();
     x.Read(s);
     return x;
 }
Exemple #2
0
        public void Read(Stream s)
        {
            BinaryReader br = new BinaryReader(s);

            magic    = br.ReadUInt32();
            command  = br.ReadBytes(12);
            length   = br.ReadUInt32();
            checksum = br.ReadBytes(4);

            switch (strcmd)
            {
            case "addr":
                payload = Addr.FromStream(s);
                break;

            case "alert":
                payload = Alert.FromStream(s);
                break;

            case "block":
                payload = Block.FromStream(s);
                break;

            case "getaddr":
                payload = GetAddr.FromStream(s);
                break;

            case "getblocks":
                payload = GetBlocks.FromStream(s);
                break;

            case "getdata":
                payload = GetData.FromStream(s);
                break;

            case "getheaders":
                payload = GetHeaders.FromStream(s);
                break;

            case "headers":
                payload = Headers.FromStream(s);
                break;

            case "inv":
                payload = Inv.FromStream(s);
                break;

            case "ping":
                payload = Ping.FromStream(s);
                break;

            case "tx":
                payload = Tx.FromStream(s);
                break;

            case "verack":
                payload = VerAck.FromStream(s);
                break;

            case "version":
                payload = Version.FromStream(s);
                break;

            default:
                payload = UnknownPayload.FromStream(s, length, command);
                break;
            }
        }