public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Patrick Strateman <patrick@intersango.com>
To: bitcoin-development@lists.sourceforge.net
Subject: Re: [Bitcoin-development] Blockchain alternative storage
Date: Wed, 05 Jun 2013 18:17:30 -0700	[thread overview]
Message-ID: <51AFE32A.2020301@intersango.com> (raw)
In-Reply-To: <CALG7eYpKj9Ev2a1PZ7qsiqsazS4pHTPiGF22r64=s1buWm2aLQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2158 bytes --]

If you're only interested in storing the best chain then a fairly simple
schema is possible.

CREATE TABLE blocks (
    hash bytea NOT NULL PRIMARY KEY,
    index integer NOT NULL UNIQUE,
    CONSTRAINT block_hash_size_check CHECK ((octet_length(hash) = (256 /
8)))
);

CREATE TABLE transaction_inputs (
    output_transaction_id bytea NOT NULL,
    output_index integer NOT NULL,
    block_index integer NOT NULL,
    CONSTRAINT transaction_id_size_check CHECK
((octet_length(output_transaction_id) = (256 / 8))),
    PRIMARY KEY (output_transaction_id, output_index)
);

CREATE INDEX transaction_inputs_block_index_idx ON transaction_inputs
USING btree (block_index)

CREATE TABLE transaction_outputs (
    transaction_id bytea NOT NULL,
    index integer NOT NULL,
    amount numeric(16,8) NOT NULL,
    type character varying NOT NULL,
    addresses character varying[],
    block_index integer NOT NULL,
    spent boolean DEFAULT false NOT NULL,
    CONSTRAINT transaction_id_size_check CHECK
((octet_length(transaction_id) = (256 / 8))),
    PRIMARY KEY (transaction_id, index)
);

CREATE INDEX transaction_outputs_addresses_idx ON transaction_outputs
USING gin (addresses);
CREATE INDEX transaction_outputs_block_index_idx ON transaction_outputs
USING btree (block_index);

On 06/05/2013 05:53 PM, Marko Otbalkana wrote:
> Could anyone point me to work/project(s) related to storing the block
> chain in a database, like PostgreSQL, MySQL? How about any tools that
> can read the block chain from the Satoshi client and convert it into
> different formats?
>
> Thanks,
> -Marko
>
>
> ------------------------------------------------------------------------------
> How ServiceNow helps IT people transform IT departments:
> 1. A cloud service to automate IT design, transition and operations
> 2. Dashboards that offer high-level views of enterprise services
> 3. A single system of record for all IT processes
> http://p.sf.net/sfu/servicenow-d2d-j
>
>
> _______________________________________________
> Bitcoin-development mailing list
> Bitcoin-development@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bitcoin-development


[-- Attachment #2: Type: text/html, Size: 3785 bytes --]

  reply	other threads:[~2013-06-06  1:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06  0:53 [Bitcoin-development] Blockchain alternative storage Marko Otbalkana
2013-06-06  1:17 ` Patrick Strateman [this message]
2013-06-06  1:49 ` Petr Praus
2013-06-06  8:20 ` Jouke Hofman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51AFE32A.2020301@intersango.com \
    --to=patrick@intersango.com \
    --cc=bitcoin-development@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox