-2

I am trying to create a blockchain based cryptocurrancy in c#. I have my blockchain class built but I realize on big problem with the current implementation. The blockchain is stored in memory in a List>. The problem I see with this is that the length of the list is a 32 bit signed integer. This is a problem if the chain get too big. Is there a way of making a List<> that has a maximum length of 9,223,372,036,854,775,807

The current way of storing the blockchain is by initializing

static Dictionary<string, Socket[]> connections = new Dictionary<string, Socket[]>();

and adding a new Dictionary for every block

  • 1
    Please see related question [What's the max items in a List?](https://stackoverflow.com/questions/2009217/whats-the-max-items-in-a-listt) – Yehor Androsov Dec 21 '18 at 20:54
  • Can you post some code? It sounds like creating a list using unsigned int for the type. – tatmanblue Dec 21 '18 at 20:54
  • I'm unclear what you are asking for. – hatchet - done with SOverflow Dec 21 '18 at 21:23
  • "or do I have to stream the chain from a file" You should be doing that even if a list could be larger than 2^31 items long. That's a *massive* amount of memory, that you appear to not even need at all, if streaming isn't a problem. You should always be streaming the content of any non-trivially sized file, if possible. – Servy Dec 21 '18 at 21:37

1 Answers1

0

I'm unclear what are you asking in question but from your title it sounds like creating a list using 64bit unsigned integer.

You can use ulong that is a 64bit unsined integer ranging from 0 to 18,446,744,073,709,551,615 and create a List<T> of ulong

var myList= new List<ulong>();
habib
  • 2,366
  • 5
  • 25
  • 41