示例#1
0
        // IStreamSerializable
        public void save(std::ostream os)
        {
            StdOutputStream stream = new StdOutputStream(os);

            CryptoNote.BinaryOutputStreamSerializer s = new CryptoNote.BinaryOutputStreamSerializer(stream);
            CryptoNote.GlobalMembers.serialize(s.functorMethod, "state");
        }
示例#2
0
        // IStreamSerializable
        public override void save(std::ostream os)
        {
            m_sync.save(os);

            StdOutputStream stream = new StdOutputStream(os);

            CryptoNote.BinaryOutputStreamSerializer s = new CryptoNote.BinaryOutputStreamSerializer(stream);
//C++ TO C# CONVERTER TODO TASK: There is no equivalent to 'const_cast' in C#:
            s.functorMethod(const_cast <uint&>(GlobalMembers.TRANSFERS_STORAGE_ARCHIVE_VERSION), "version");

            ulong subscriptionCount = m_consumers.Count;

            s.beginArray(ref subscriptionCount, "consumers");

            foreach (var consumer in m_consumers)
            {
                s.beginObject("");
//C++ TO C# CONVERTER TODO TASK: There is no equivalent to 'const_cast' in C#:
                s.functorMethod(const_cast <PublicKey&>(consumer.first), "view_key");

                std::stringstream consumerState = new std::stringstream();
                // synchronization state
                m_sync.getConsumerState(consumer.second.get()).save(consumerState);

                string blob = consumerState.str();
                s.functorMethod(blob, "state");

                List <AccountPublicAddress> subscriptions = new List <AccountPublicAddress>();
                consumer.second.getSubscriptions(subscriptions);
                ulong subCount = subscriptions.Count;

                s.beginArray(ref subCount, "subscriptions");

                foreach (var addr in subscriptions)
                {
                    var sub = consumer.second.getSubscription(addr);
                    if (sub != null)
                    {
                        s.beginObject("");

                        std::stringstream subState = new std::stringstream();
                        Debug.Assert(sub);
                        sub.getContainer().save(subState);
                        // store data block
                        string blob = subState.str();
                        s.functorMethod(addr, "address");
                        s.functorMethod(blob, "state");

                        s.EndObject();
                    }
                }

                s.EndArray();
                s.EndObject();
            }
        }