コード例 #1
0
 public NodeKey(Unpacker unpacker, int unpackerStartPosition)
 {
     unpacker.Unpack(out ChainId);
     unpacker.Unpack(out ChainIndex);
     unpacker.Unpack(out KeyIndex);
     KeyFlags = (PublicChainKeyFlags)unpacker.UnpackLong();
     (_signatureHash, _signature) = unpacker.GetHashAndSignature(unpackerStartPosition, unpacker.Position - unpackerStartPosition);
 }
コード例 #2
0
        protected override void PostSignatureUnpacked(Unpacker unpacker, int messageSize)
        {
            if (IsCoreNode)
            {
                var startPosition = unpacker.Position - messageSize;

                (_coreVoteDataHash, _coreVoteSignature) = unpacker.GetHashAndSignature(startPosition, messageSize);
            }
        }
コード例 #3
0
        protected override void PostUnpack(Unpacker unpacker, int unpackerStartPosition)
        {
            base.PostUnpack(unpacker, unpackerStartPosition);

            var dataSize = unpacker.Position - unpackerStartPosition;

            (SignatureHash, Signature) = unpacker.GetHashAndSignature(unpackerStartPosition, dataSize);
            UniqueIdentifier           = BitConverter.ToInt64(SignatureHash.RawData.Array, 0);

            if (HasMetaData)
            {
                MetaData.Unpack(unpacker, _features, _unkownFeatures);
            }
        }
コード例 #4
0
ファイル: Message.cs プロジェクト: HeleusCore/Heleus.Base
        public static T Restore <T>(Unpacker unpacker) where T : Message
        {
            var startPosition = unpacker.Position;

            unpacker.Unpack(out ushort Magic);

            var signed = false;

            if (Magic == MessageMagicSigned)
            {
                signed = true;
            }
            else if (Magic != MessageMagic)
            {
                throw new Exception("Invalid message");
            }

            unpacker.Unpack(out ushort protocolVersion);
            unpacker.Unpack(out uint size);
            unpacker.Unpack(out ushort messageType);

            if (_messageTypes.TryGetValue(messageType, out Type type))
            {
                var m = (T)Activator.CreateInstance(type);

                m.ProtocolVersion = protocolVersion;
                m.Size            = size;
                unpacker.Unpack(m.Unpack);

                if (signed)
                {
                    var dataSize = unpacker.Position - startPosition;
                    (m.SignatureHash, m.Signature) = unpacker.GetHashAndSignature(startPosition, dataSize);
                    m.PostSignatureUnpacked(unpacker, (int)size);
                }
                return(m);
            }

            Log.Fatal($"Could not restore message with message type {messageType}");

            return(null);
        }
コード例 #5
0
        protected override void PostSignatureUnpacked(Unpacker unpacker, int messageSize)
        {
            var startPosition = unpacker.Position - messageSize;

            (_dataHash, _signature) = unpacker.GetHashAndSignature(startPosition, messageSize);
        }