Example #1
0
	bool FindTx(const HashValue& hash, Tx *ptx) override {
		EXT_LOCK (MtxSqlite) {
			DbDataReader dr = m_cmdFindTx.Bind(1, ReducedHashValue(hash)).ExecuteReader();
			if (!dr.Read())
				return false;
			if (ptx) {
				ptx->EnsureCreate();
				ptx->SetHash(hash);
				LoadFromDb(*ptx, dr);
			}
		}
		return true;
	}
Example #2
0
	bool FindTxById(const ConstBuf& txid, Tx *ptx) override {
		EXT_LOCK (MtxSqlite) {
			DbDataReader dr = m_cmdFindTx.Bind(1, *(Int64*)txid.P).ExecuteReader();
			if (!dr.Read())
				return false;
			if (ptx) {
				ptx->EnsureCreate();
				ptx->SetReducedHash(txid);
				LoadFromDb(*ptx, dr);
			}
		}
		return true;
	}
Example #3
0
	DomainData Resolve(RCString domain) override {
		if (!ResolverMode)
			Throw(E_NOTIMPL);
		DomainData r;
		EXT_LOCK (MtxSqlite) {
			DbDataReader dr = m_cmdFindDomain.Bind(1, domain).ExecuteReader();
			if (dr.Read()) {
				r.AddressData = dr.GetString(0);
				r.Height = dr.GetInt32(1);
			}
		}
		return r;
	}
Example #4
0
	vector<Block> GetBlocks(const LocatorHashes& locators, const HashValue& hashStop) override {
		vector<Block> r;
		int idx = locators.FindIndexInMainChain();
		EXT_LOCK (MtxSqlite) {
			SqliteCommand cmd(EXT_STR("SELECT id, hash, data, txhashes FROM blocks WHERE id>" << idx << " ORDER BY id LIMIT " << 2000 + locators.DistanceBack), m_db);
			for (DbDataReader dr = cmd.ExecuteReader(); dr.Read();) {
				Block block = LoadBlock(dr);
				r.push_back(block);
				if (Hash(block) == hashStop)
					break;
			}
		}
		return r;
	}
Example #5
0
DbDataReader SqliteCommand::ExecuteVector() {
	DbDataReader r = SqliteCommand::ExecuteReader();
	if (!r.Read())
		Throw(ExtErr::DB_NoRecord);
	return r;
}
Example #6
0
	Blob FindPubkey(Int64 id) override {
		EXT_LOCK (MtxSqlite) {
			DbDataReader dr = CmdPubkeyIdToData.Bind(1, id).ExecuteReader();
			return dr.Read() ? Blob(dr.GetBytes(0)) : Blob(nullptr);
		}
	}
Example #7
0
	Block FindBlock(const HashValue& hash) override {
		EXT_LOCK (MtxSqlite) {
			DbDataReader dr = m_cmdFindBlock.Bind(1, ReducedBlockHash(hash)).ExecuteReader();
			return dr.Read() ? LoadBlock(dr) : Block(nullptr);
		}
	}
Example #8
0
	int GetNameHeight(const ConstBuf& cbufName, int heightExpired) override {
		DbDataReader dr = m_cmdNameHeight.Bind(1, ToStringName(cbufName)).ExecuteReader();
		return dr.Read() ? dr.GetInt32(0) : -1;
	}