Exemplo n.º 1
0
        public static AccountState FromBytes(byte[] bytes)
        {
            var cursor = new CursorBuffer(bytes);

            var authenticationKeyLen = cursor.Read32();
            var authenticationKey    = cursor.ReadXBytes((int)authenticationKeyLen);
            var balance = cursor.Read64();
            var delegatedKeyRotationCapability = cursor.ReadBool();
            var delegatedWithdrawalCapability  = cursor.ReadBool();

            var receivedEventsCount = cursor.Read32();

            cursor.Read32(); // skip struct attribute sequence number
            var receivedEventsKeyLen = cursor.Read32();
            var receivedEventsKey    = cursor.ReadXBytes((int)receivedEventsKeyLen);

            var sentEventsCount = cursor.Read32();

            cursor.Read32(); // skip struct attribute sequence number
            var sentEventsKeyLen = cursor.Read32();
            var sentEventsKey    = cursor.ReadXBytes((int)sentEventsKeyLen);

            var sequenceNumber = cursor.Read64();

            var receivedEvents = new EventHandle(receivedEventsKey, receivedEventsCount);
            var sentEvents     = new EventHandle(sentEventsKey, sentEventsCount);

            return(new AccountState(authenticationKey, balance, receivedEvents, sentEvents, sequenceNumber, delegatedWithdrawalCapability, delegatedKeyRotationCapability));
        }
Exemplo n.º 2
0
        public void ReadXBytes()
        {
            var bytes  = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            var cursor = new CursorBuffer(bytes, 1, bytes.Length - 1);
            var actual = cursor.ReadXBytes(3);

            actual = cursor.ReadXBytes(3);
            actual = cursor.ReadXBytes(3);
            var expected = new byte[] { 8, 9, 10 };

            Assert.True(actual.SequenceEqual(expected));
        }
Exemplo n.º 3
0
        public static AccountState FromBytes(byte[] bytes)
        {
            var cursor = new CursorBuffer(bytes);

            var authenticationKeyLen = cursor.Read32();
            var authenticationKey    = cursor.ReadXBytes((int)authenticationKeyLen);
            var balance = cursor.Read64();
            var delegatedWithdrawalCapability = cursor.ReadBool();
            var receivedEventsCount           = cursor.Read64();
            var sentEventsCount = cursor.Read64();
            var sequenceNumber  = cursor.Read64();

            return(new AccountState(authenticationKey, balance, receivedEventsCount, sentEventsCount, sequenceNumber, delegatedWithdrawalCapability));
        }