Solana: when the program is deployed, modifying the data structure

Edit data structures on Solana: understanding of updating paths

Solana is a decentralized, fast and secure blockchain platform that allows you to develop the only language applying to variance, rust. One of the key characteristics of Solana is the ability to modify the structures in the execution phase, allowing a flexible and efficient development.

Wen is distributed your program on Solana, you can update it and make shops in certain fields. This date requires the dates that slicate changes during the update and what happens when these fields change.

The stratto before the update *

We consider an example structure, let’s say User ', which has properties as Id (a unique identifier),name' (the user's name) is EMAIL (the user's e -mail address):

Rust

STROCT User {

ID: U64,

Name: string,

Email: string,

}

In Solana, one is distributed a program, the data are immutable to runtime. It means that Souly is distributed, its fields cannot be changed.

Modify fields after updating

Suppose that after distributing the program, it is necessary to stand it and Chaange Soome Fields in stress "user", Souch such as:

Rust

STROCT User {

ID: U64,

Name: string,

Email: string,

}

IMPL User {

Fn Update_name (& mut self, new_name: string) {

self.name = new_name;

}

Fn Update_email (& mut self, new_email: string) {

self.email = new_email;

}

}

To change those after the update, you will have to this new request for an application forUser with the updated values:

`Rust

Let Mut User = User {User

ID: 1,

Name: "John Doe" .to_string (),

Email: "John.doe@example.com" .to_string (),

};

User.update_name ("Jane Doe" .to_string ());

User.update_email (jane.doe@example.com.to_string ());

Println! ("Updated data:");

Println! ("":?} ", preser);

What happens when the fields change?

When you change the after all upgrading fields, Solana's Runtime for any changes to the field that point the behavior of the program. In this case, the modification of the fieldsName ‘is and -mail it will be corresponding to the values ​​in history.

Gere are some key points to note:

  • The modification fields directly on a distributed stroct note the below.

  • Changing the update of the fields creates new instances of the situation with updated values.

  • The controls of Runtime di Solana for any changes in the field that affect the program, guaranteeing consistency and accuracy.

In summary, the modification of the fields in a Stroctafter that updates the program on Solana requires the creation of news of the application for the space. This is underestimated the information below the approach guarantee and accurate the refresher process.

Solana Larger Than 67108864

Leave a Reply

Your email address will not be published. Required fields are marked *